moderngl: Alpine Linux: Context.release() memory leak
Hello, I created a moderngl context in Python and called context.release()
, but the memory never gets released.
Here it is the code:
import gc
import moderngl.mgl as mgl
from moderngl.context import Context
ctx = Context.__new__(Context)
ctx.mglo, ctx.version_code = mgl.create_context(glversion=330, mode="standalone")
ctx.release()
del(ctx)
gc.collect()
There is approximately 50MB of memory that is not being released even after context.release()
, del(context)
or gc.collect()
, so how can I retrieve this memory back? I would really appreciate any help on this!
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 24 (13 by maintainers)
Hello, @szabolcsdombi , I solved the git clone issue. Me and @ShootingStarDragon have been commenting every line from x11.cpp, compiling and profiling, and we suddenly found that the memory leak happens in GLXFBConfig * fbc, in which the memory decreased from 50MB to 3.3MB.
Before commenting this line:
After commenting this line:
We believe frame buffer context should be released at the end somehow
Some (hopefully useful) references: https://registry.khronos.org/OpenGL-Refpages/gl2.1/xhtml/glXChooseFBConfig.xml
https://www.khronos.org/opengl/wiki/Tutorial:_OpenGL_3.0_Context_Creation_(GLX) in this tutorial there is this comment
good catch. I look into the docs how to release it.
I soon add this code to glcontext, you will be able to test as before.
I remember fixing a leak in the past and added a mass create test : https://github.com/moderngl/glcontext/blob/master/tests/default_context_test.py