-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Memory leak in ThreadLocalRegistryImpl::GetThreadLocalsMapLocked() on Windows #692
Comments
That would make things worse as local variables are destroyed after GetThreadLocalsMapLocked returns. |
@nachokruss local yes, but static are not. |
Aha. You are right didn't see it was static, maybe put in a pull request then? |
Thanks for comments. I will create pull request in near future. |
This is not a leak per se (where a leak is defined as "allocated memory Put another way, that object is always reachable, so it's not a leak. So far as I am aware (maybe the gtest owners want to comment more Is there an argument (other than hygeine / warnings from the leak detector On Tue, Jan 26, 2016 at 2:28 PM, Zbigniew Rębacz [email protected]
|
Its annoying to find real leaks with lots of on purpose leaked objects :) |
Should be addressed by #1142 |
I started out with ~1800 leaks and got it down to zero. Some are in google's test code itself (see google/googletest#692 ) though it looks like they might not be interested in fixing them. 1600 leaks were in not having a virtual OpKernel destructor. 150 leaks were in not calling ::google::protobuf::ShutdownProtobufLibrary the rest were in our statics Scott - I reverted some of the gsl changes as the static pointers were never being destroyed. Doesn't the initialization order only apply to global statics, not function ones?
Hello,
I am trying to port gtest to U++ bazar project (www.ultimatepp.org) , but it's memory dectors shows that there are memory leaks on MS Windows. I fount that one of this leaks comes from static ThreadLocalRegistryImpl method "ThreadIdToThreadLocals* GetThreadLocalsMapLocked()" - gtest-port.cpp - line 532. Below is the original implementation:
As you can see the problem here is that this static variable is never deleted in the gtest code. The solution here is simply, instead of allocating on stack let's allocate this on heap:
In this solution destructor of ThreadIdToThreadLocals will be called when all static variable should be cleaned.
Sincerely,
Zbigniew Rębacz
The text was updated successfully, but these errors were encountered: