eth-ait / aitviewer

A set of tools to visualize and interact with sequences of 3D data.
MIT License
497 stars 46 forks source link

How to release the memory after exporting the video in headless rendering? #53

Closed kunkun0w0 closed 2 months ago

kunkun0w0 commented 3 months ago

Hi~ I encountered a memory problem when using headless rendering multiple times. The memory occupancy will accumulate till the system shuts down. I tried to reset the viewer and release the renderable nodes after saving the video. However, it does not work.

self.viewer = HeadlessRenderer()

def rendering_loop(self, ...):
     self.viewer.reset()
     obj = Skeletons(...)
     self.viewer.scene.add(obj)
     self.viewer.lock_to_node(obj)
     self.viewer.save_video(...)
     obj.release()

I checked line by line and found that the memory usage suddenly increased after the self.viewer.save_video.

Would you like to give me some suggestions to solve this?

kaufManu commented 3 months ago

Yes, I am aware of this unfortunate issue. We think it's due to a memory leak in moderngl-window. The related issue is here, and although it is closed, the problem does not appear to be fixed according to the latest comments.

Two things help: