By default, the Sphere class (and all of the Primitives) share their geometry. The 
Sphere class maintains a reference to that Sphere geometry so it can be shared when 
another Sphere with the same properties is desired. So, even if you remove the Sphere 
from the scene graph, it will not be GCed. You must set the GEOMETRY_NOT_SHARED 
capability flag on Sphere construction if you do not want this behavior.

Sean

> -----Original Message-----
> From: ZACZEK, MARIUSZ P. (MARIO) (JSC-DM) (NASA)
> [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, March 05, 2003 8:49 AM
> To: [EMAIL PROTECTED]
> Subject: [JAVA3D] ? Garbage Collection - memory does not decrease ?
> 
> 
> 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".

Reply via email to