gazebosim / gz-gui

Builds on top of Qt to provide widgets which are useful when developing robotics applications, such as a 3D view, plots, dashboard, etc, and can be used together in a convenient unified interface.
https://gazebosim.org
Apache License 2.0
67 stars 39 forks source link

[Scene3D] Memory leak on resize #35

Open osrf-migration opened 5 years ago

osrf-migration commented 5 years ago

Original report (archived issue) by Louise Poubel (Bitbucket: chapulina, GitHub: chapulina).


When resizing the scene 3D plugin, I can see using top that the memory almost doubles each time the window is resized.

I traced it down to these lines on Scene3D. If I comment out SetImageWidth, SetImageHeight and SetAspectRatio, the issue doesn't happen.

The comment on the code, setting the size should cause the render texture to be rebuilt led me to OgreRenderTarget::RebuildImpl. There are some "destroy" functions which are not implemented there.

I started trying to implement them here (ignitionrobotics/ign-rendering@1af343b85b9f5e4d01faeca095a9b1b95d223e4c), but the memory leak is still happening.

@iche033 , any tips?

osrf-migration commented 5 years ago

Original comment by Ian Chen (Bitbucket: Ian Chen, GitHub: iche033).


mm maybe also try clean up render target by calling RenderTarget::removeAllListeners and RenderTarget::removeAllViewports, and also unloading the texture using TextureManager::unload before removing the texture?

osrf-migration commented 5 years ago

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).


osrf-migration commented 5 years ago

Original comment by Louise Poubel (Bitbucket: chapulina, GitHub: chapulina).


Added all the suggestions, see here, there's still a leak. I think we may need to use some profiler to investigate.

osrf-migration commented 5 years ago

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).


Valgrind could help.

osrf-migration commented 5 years ago

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).


Checking in on this task to make sure it's still on the radar.

osrf-migration commented 5 years ago

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).


➤ Louise commented:

I'll get back to it now that the docking is under review

osrf-migration commented 5 years ago

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).


➤ Ian Chen commented:

I can help if you need a hand

osrf-migration commented 5 years ago

Original comment by Louise Poubel (Bitbucket: chapulina, GitHub: chapulina).


This PR reduces the leak, but there's still some: https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-rendering/pull-requests/108/improve-target-rebuilding/diff

osrf-migration commented 5 years ago

Original comment by Ian Chen (Bitbucket: Ian Chen, GitHub: iche033).


Another PR: https://osrf-migration.github.io/ignition-gh-pages/#!/ignitionrobotics/ign-rendering/pull-requests/110

iche033 commented 3 years ago

found a related post in ogre forum about depth buffer textures not being cleaned up in ogre 2.x