danini-the-panini / mittsu

3D Graphics Library for Ruby.
https://github.com/danini-the-panini/mittsu
MIT License
508 stars 33 forks source link

Memory leak in several examples #118

Open sonicblue7real opened 6 months ago

sonicblue7real commented 6 months ago

Platform: Linux Ruby version: 3.0.2p107 Mittsu OpenGL Renderer 0.4.0

Running several examples like 02_geometries, 05_earth and 07_earth_normal showcases continuous memory increase.

sonicblue7real commented 6 months ago

I just discovered something interesting by accident, in the 05_earth example not adding the light_object into the scene but instead using a ambient light: light2 = Mittsu::AmbientLight.new(0xffffff) ; scene.add(light2) doesn't result in the same memory leak.

sonicblue7real commented 6 months ago

Unfortunately just adding a single obj file to a scene with that ambient light does again result in continuously increasing memory. From the GC.stats it looks like it's allocating more (total objects) than it's freeing.

sonicblue7real commented 6 months ago

Some new information after running more tests and looking at Ruby's memory usage: If even a single sphere is added to a basic scene, the memory issue persists (slowly leaking memory)... however, if I after X minutes remove that sphere from the scene (with scene.remove) the memory leak stops.

sonicblue7real commented 6 months ago

So I just discovered that even setting the visibility to false of the object at runtime stops the leak, making it again visible continues to leak memory.