Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lazy initialization #4150

Merged
merged 1 commit into from Jun 30, 2015
Merged

Conversation

alalek
Copy link
Member

@alalek alalek commented Jun 23, 2015

@vpisarev vpisarev self-assigned this Jun 29, 2015
@vpisarev
Copy link
Contributor

👍

@FrankHeimes
Copy link

Where did the original detailed issue description http://code.opencv.org/issues/4428 go?
The domain has changed and I can't find it on https://github.com/opencv/opencv/issues.
I'd really like to learn the exact reasons why I should have to live with memory leak as long as I'm using OpenCV.
The static initialization chaos alone is no longer a reason when using C++11 and Meyers Singleton pattern.

@FrankHeimes
Copy link

@soechin: @alalek is right saying that your solution doesn't work because __initialization_mutex may be not be initialized before getInitializationMutex() is called by another static initializer.

But this should work with C++11:

Mutex& getInitializationMutex()
{
  static Mutex instance; // Initialization is thread-safe
  return instance;
}

especially if no (non-constexpr) static variables exist in global scope.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants