Bryan Pendleton <[EMAIL PROTECTED]> 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
