pyrender
pyrender copied to clipboard
Memory leak on glReadPixels with recent version of PyOpenGL-accelerate
When the version of PyOpenGL-accelerate doesn't match the version of PyOpengl (eg. PyOpenGL==3.1.0 with PyOpenGL-accelerate==3.1.5) the memory usage of the process increases uncontrollably (even though in theory they should be compatible).
This is different from https://github.com/mcfletch/pyopengl/issues/47, where a texture is created multiple times. In this case the texture is not present at all, only render function called multiple times.
The leak seems to occur on glReadPixels: https://github.com/mmatl/pyrender/blob/master/pyrender/renderer.py#L1180
import os
from sys import platform
import pyrender
from io import BytesIO
import numpy as np
import trimesh
import requests
duck_source = "https://github.com/KhronosGroup/glTF-Sample-Models/raw/master/2.0/Duck/glTF-Binary/Duck.glb"
mesh = trimesh.load(BytesIO(requests.get(duck_source).content), file_type='glb')
for m in mesh.geometry.values():
m.visual.material.baseColorTexture = None
if platform != "win32":
os.environ['PYOPENGL_PLATFORM'] = 'egl'
scene = pyrender.Scene()
scene.add(pyrender.Mesh.from_trimesh(list(mesh.geometry.values())))
scene.add(pyrender.PerspectiveCamera(np.radians(60)))
r = pyrender.OffscreenRenderer(640, 480)
i = 0
while True:
print(i)
im = r.render(scene)
i += 1
memory usage looks like this:
same issue
I have pretty the same issue. Running code on the headless server with 'egl' backend. I am doing offscreen renderer and with each run memory leaks away. At the same time I don't have PyOpenGL-accelerate installed at all, only PyOpengl. @mich-sanna you're saying that you can see bug when version doesn't match, but with both frameworks of the same version everything works as intended? Please give some comment here. I'll try to install PyOpenGL-accelerate of the same version, but I hardly believe it will fix anything.
@mmatl it would be great to have any comment on this