> From: "John A. Tenney" <[EMAIL PROTECTED]>
>
> In my application, I need to create and delete objects fairly often. I create
> the objects as a BranchGroup, and when I want to delete them, I use the
> detach() function. Everything seems to work, but memory consumption
> continues to ramp and performance gets increasingly slow. Is there
> something I need to do besides detach() to allow detached BranchGroups
> to become garbage collected? I am quite sure that I don't keep
> references to the detached BranchGroups myself, so I've done everything
> I can do to enable garbage collection.

Be sure that you are not keeping references to any part of the BranchGroup you
want to get rid of, such as an Apppearance, Geometry etc.  Similarly, make sure
you are not sharing any part of the BranchGroup with a BranchGroup you are
continuing to use (again, sharing Appearances are a common problem here).

Finally, you may find that breaking down the BranchGroup after the detach helps
the problem.  Do this by walking the tree, nulling out the geometry and
appearance for each Shape and nulling out the children of each group.  Do this
*after* you detach() so that you don't have to worry about cap bits.

A tool like OptimizeIt can be used to see the erroneous references to the
detached() BG.  Print out the BG's address before you null the reference and
then use OptimizeIt to see if that BG is still present after you GC. If it is,
trace back the BG reference to it's root and look for the bad reference.

Doug Gehringer
Sun Microsystems

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to