-
Notifications
You must be signed in to change notification settings - Fork 372
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 shaderc_compiler_initialize #1052
Comments
per libshaderc_util/include/libshaderc_util/compiler.h, GlslangInitializer is a Singleton, so though this is technically memory leak, it isn't a bug. Admittedly the Singleton pattern has not been correctly implemented here, so that should be corrected. This all should in theory go away with resolving #945 I am going to confirm whether I should refactor this to be a proper Singleton, or if I should just rip it all out. |
Interesting. Either way, the singleton should be deleted (I use a "nifty counter" singleton for this) I've noticed another memory leak deep in the shader compiler, but it seems to only happen in release mode so I've not had a chance to get a clear picture of what's causing it yet (It could just be an std artifact with my memory tracker). I would recommend you to run some tests with a memory leak tracker :) This is the callstack of the allocation that's leaking (all the info I have):
|
Just looked at the bot configs for what sanitizers we are running. There is an ASAN config that is part of kokoro:run, which wouldn't catch leaks, though will catch some other issues. We should probably also add a LSAN bot at least to catch leaks. For other sanitizers, MSAN & UBSAN could potentially be useful, but if I recall correctly they are more difficult to setup/noisy. I have filed #1053 for looking into increasing the sanitizer coverage. |
FYI. Years ago our team discussed the tradeoffs of leaking these singleton objects. At the time we chose to deliberately leak them rather than deal with the complexity of correctly releasing them, e.g. in the presence of multiple threads. The nifty counter (just looked it up), relies C++ constructors and destructors for objects of static duration (so they're initialized before main() and destroyed after exit). That is against Google C++ style for important reasons. https://google.github.io/styleguide/cppguide.html#Static_and_Global_Variables In any case, I'm happy for @zoddicus to safely eliminate the mutex around Glslang, which will eliminate one singleton. Looking at the stack trace, and drawing on experience from over a decade ago, text processing in the C++ standard IO stream uses allocated objects to manage locale translations, particularly for text and numbers. That may be what's leaking here. If that's the case, it may be out of our hands, and is really the responsibility of the underlying C++ runtime. |
Marking this issue as closed, since #1059 reduces the leak to a single std::mutex, and we have filed other work items to improve sanitizer coverage. |
static shaderc_util::GlslangInitializer* initializer =
new shaderc_util::GlslangInitializer;
is never deleted.
This causes a whole chain reaction of memory leaks.
The text was updated successfully, but these errors were encountered: