Memory Leaks caused by Singletons
- Dominant language
- C++
- Stars
- 2.2k
- Forks
- 445
- Avg merge
- 11h 6m
- Merged PRs (30d)
- 6
Description
Using shaderc in our code consistently causes ~5.5MB of leaked memory. The issue seems to stem from singletons in shaderc_compiler_initialize and some callee in shaderc_compile_into_spv(CompileToSpecifiedOutputType).
Subsequent compiler initializations don't cause additional leaks.
I understand that resources will be cleared when exiting the program, but we don't want keep around that memory, the example-usage in shaderc.hpp seem to imply that it wasn't necessary as well.
On top of that it shadows our memory leaks since a total of 1252 leaks are caused by shaderc.
See this super simple code example that suffers from the leaks:
```
#include
#include
int main(int argc, char **argv) {
{
shaderc_compiler_t compiler = shaderc_compiler_initialize();
{
char *shader = "#version 430 void main() {}";
size_t size = strlen(shader);
shaderc_compilation_result_t compileResult = shaderc_compile_into_spv(
compiler, shader, size,
shaderc_shader_kind::shaderc_glsl_default_fragment_shader, "test.frag", "main", nullptr);
shaderc_result_release(compileResult);
} // Leaks 5259.32 KB
shaderc_compiler_release(compiler);
} // Leaks 386.32 KB
return 0;
}
````
Contributor guide
Assessment
This issue has not been assessed yet.