db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Knut Anders Hatlen <Knut.Hat...@Sun.COM>
Subject Re: Nulling out variables for GC
Date Fri, 23 Feb 2007 17:51:17 GMT
Bryan Pendleton <bpendleton@amberpoint.com> writes:

>> in the datatype code for a binary object, the value may change from
>> a 30Mb array to a 2 byte array, so nulling out the reference before
>> creating a new one is good. 
> Is there any value to explicitly calling System.gc() in a situation
> such as this?

I don't think so. The JVM should be clever enough to start a GC on its
own if it doesn't have enough memory. But you never know... :) By
calling System.gc() explicitly, you will start a GC regardless of the
need for a GC, so it might cost more than you win.

I have seen calls to System.gc() and System.runFinalization() some
places in the code. I don't think those calls are there primarily to
reclaim space, but to make sure (or more accurately: increase the
probability) that the finalizers for unreferenced objects have been
run so that they release whichever resources they may be holding.

Knut Anders

View raw message