This minimum working example of an environment with PyOpenGl and GLUT presents the same issue I am having on bigger code. Creating/closing continuously an instance of this class, increases memory usage until all my machine starts slowing down.
What is happening is that the call to glutDestroyWindow has not effect and the process /usr/lib/xorg/Xorg quickly fills up the whole GPU.
from OpenGL.GLUT import *
DISPLAY_WIDTH, DISPLAY_HEIGHT = 2000, 2000
class TestEnv:
def __init__(self):
self.window = None
glutInit(sys.argv)
glutInitWindowSize(DISPLAY_WIDTH, DISPLAY_HEIGHT)
self.window = glutCreateWindow(b"TestEnv")
def close(self):
if self.window:
glutDestroyWindow(self.window)
if __name__ == "__main__":
i = 0
while True:
env = TestEnv()
env.close()
print(i)
i+=1
What is the correct way of releasing all resources?