Skip to main content

How to get rid of retain objects (memory leak?)

4 replies [Last post]
Anonymous

I use Java3d for 3dimensional claculations. Therefore I have an offscreen canvas. In my universe I register in a main branchgroup several Shapes (containing a few Triangle and Quadarryas). With this objects and some picking operations I do my calculations. Afterwards I remove the main branchgroup form the universe.
I think, all should be then away...
but when I take a look on the heap, I see a lot of "retainobjects" (like retainedTriangleArray and retainedQuadArryas, retained branchgroup...etc.). After every calculation, the retainobjects stay in the heap and will be more and more...
Does anybody know what to do, to get rid of all these memory garbage?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Anonymous

There is a bug causing Java 3D to hold onto some of the memory in the last branch group you removed:

https://java3d.dev.java.net/issues/show_bug.cgi?id=75

BranchGroup emptyGroup = new BranchGroup();
emptyGroup.setCapability(BranchGroup.ALLOW_DETACH);
universe.getLocale().addBranchGraph(emptyGroup);
universe.getLocale().removeBranchGraph(emptyGroup);
emptyGroup = null;

messengers
Offline
Joined: 2004-04-18
Points: 0

>Does anybody know what to do, to get rid of all these memory garbage?

see the wiki entry

http://wiki.java.net/bin/view/Javadesktop/Java3DApplicationDevelopment#R...

regards

rsmogura
Offline
Joined: 2008-06-02
Points: 0

I tired with detach and removeAllChildren, nulling, but it's looks key point is to call SimpleUnivers.cleanup() (I do it after all nulling detaching etc).

So keep a reference to SimpleUniverse.

harveyh
Offline
Joined: 2005-01-01
Points: 0

What version of Java3D are you using? If you use JVisualVM and do a heap dump, can you identify
what objects are being leaked.

I maintain a fork of Java3d here:
https://github.com/hharrison/java3d-core

Maybe that will work better for you.

Cheers,

Harvey