Greg:

Note my wording:  "You can force the garbage collection _somewhat_ by
calling System.gc()."

Garbage collection in Java seems to be slow at best, but if objects have
no references remaining and you set them to null, you are likely to get
garbage collection and _if_ garbage collection occurs on an object, at
that point it _is_ guaranteed that finalize will be called, which is
what I said.  GC is not guaranteed, but if it occurs, then finalize is
guaranteed, and through finalize, you can debug and track the gc.  I
have done this for Shapes, BranchGroups, etc, and I found that many of
them are actually being collected by the garbage collector.  The gc is
just a very low priority thread.

Perhaps a Sun person could comment further.  

Have a great day,

Chris

>From the Java 2 API, System class:

public static void gc()
Runs the garbage collector. 
Calling the gc method suggests that the Java Virtual Machine expend
effort toward recycling unused objects in order to make the memory they
currently occupy available for quick reuse. When control returns from
the method call, the Java Virtual Machine has made a best effort to
reclaim space from all discarded objects. 

The call System.gc() is effectively equivalent to the call: 

Runtime.getRuntime().gc()

 
-----Original Message-----
From: Greg Munt [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 16, 2001 10:39 AM
To: [EMAIL PROTECTED]
Subject: Re: [JAVA3D] Memory handling


This is just not true. Garbage collection is never guaranteed to happen.
Ever. (This means that finalizers are never guaranteed to run, ever.)
System.gc is not guaranteed to do ANYTHING. For this reason, I fail to
see
the point of its existence, actually.

-----Original Message-----
From: Christopher Collins <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Monday, July 16, 2001 01:34
Subject: Re: [JAVA3D] Memory handling


[snip]

You can force the garbage collection somewhat by calling System.gc().

========================================================================
===
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