|
ChrisE
|
 |
« on: 08. March 2011, 06:50:08 pm » |
|
Marvin,
Context So, I've got a large scene graph, with some depth in the tree but a *lot* of leaf nodes--in order to get good transparency, I'm giving each triangle in a sphere its own Shape3D (yes, this is wrong; no, it isn't permanent). I have a lot of nested spheres. This is intended just to illustrate the problem context.
Problem The problem comes when I want to clean up the renderer. I use it in a sort of time-sharing method, so I frequently remove the entire scene and put other things into it.
Several of cycles of this will result in an OutOfMemory exception.
Investigation Examining the heap with Jhat shows me that extra copies of Shape3D and Point3f, along with SceneGraphOpenGLReferences, BoundingSphere, and so on, are being held. Several objects without references at a higher level are also being held.
Interestingly enough, if I call System.GC after every scene freeing operation--and yes, not something I would do outside of troubuleshooting--I notice that the memory is reclaimed, and the bogus objects go away. This tells me that we aren't outright leaking memory, but that only the presumably more aggressive system GC can catch whatever is happening.
Theory
Examining the code, I see that a lot of the objects keep references to themselves, their parents, their children, etc., and so are probably hard to garbage collect incrementally.
Xith seems to have its own way of trying to handle memory management, and this doesn't quite seem to be working.
Question Is there a way to force Xith to remove all of its scenegraphs, branchgroups, nodes, resources, soups, and whatever else it might have allocated (without actually shutting it down and bringing it back up again)?
Is there a way of being sure to completely free a node and its children?
Thanks! -Chris
|