I believe that when you remove the children, those children are taken out of the branchgroup but the references to those children still are valid so GC did not remove them. GC will probably removes those children later on when it determined that the children are no longer being used. A simple method to trick GC to collect the removed children would be setting the children to null after you removed them from the branchgroup (to the best of my knowledge, try it out)
t
At 10:49 AM 3/5/2003 -0600, you wrote:
Below is a copy of a post someone put to this group in 1998!!! There was no answer in that thread and searching the archives I have not yet found an answer...so, I'm going to ask you all about it. Do you know how to get back the memory after removing a child from a parent?
I run my code where I have a function to add 3D spheres to a 3D canvas:
void addSpheres() { for (int i=0; i<1000; i++) mainBranchGroup.addChild(new sphere(...)); }
Later on I remove the spheres:
void removeSpheres() { mainBranchGroup.removeAllChildren(); }
BUT, running java -verbose:gc myProgram Shows NO decrease in memory....I only see a steady increase in memory used as I add more spheres, but if I remove them I don't see any memory decrease.
I am quite confident I have NO reference to the new sphere() anywhere else so I don't see why the memory should not be released....any hints/thoughts/suggestions? ... or is this a persistent problem in Java3D?
I've also tried the System.gc(); call periodically but I find that it does nothing for me... and by the Javadocs for it I can see that this call MAY or MAY NOT do anything...kind of wierd.
Thanks,
Mario
>> -----Original Message----- >> From: Jon Barrilleaux [SMTP:[EMAIL PROTECTED] >> Sent: Friday, October 09, 1998 2:25 PM >> Subject: [java3d] garbage collection after removing nodes >> >> Someone reported on this list a while back that memory was not being >> freed after releasing a large number of Group nodes. I never saw an >> answer to this on the list. >> >> I've observed a similar problem. I create a large scene in a >> BranchGroup and add it to my scene. Memory usage goes up. After >> removing it from its parent BranchGroup and then running System.gc() >> the memory usage does not change. I'm pretty sure that I don't have a >> lingering reference. Repeating this cycle of adding a new scene graph >> and then removing it only causes the memory size to grow. >> >> Is this a known bug or am I missing something? >> >> --jon
Mario
Mariusz Zaczek NASA - Johnson Space Center Automated Vehicles and Orbit Analysis / DM35 Flight Design and Dynamics Division Mission Operations Directorate Bldg: 30A Room: 3040A
Disclaimer: "The opinions, observations and comments expressed in my email are strictly my own and do not necessarily reflect those of NASA."
=========================================================================== 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".
=========================================================================== 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".
