NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
Hi Nash'at, My understanding of java rubbish collection was that the rubbish collector is run under a low priority thread. Added to the fact that classes or instances of classes may be interlinked with other instances and other classes, by setting references to null triggers chain reactions - which may have been the reason why the automatic memory management does not seem to occur instantenously. If conservation of memory is of ultimate essence, and if time taken to release the reuasble memory is not of too cencern, the following may be useful to you, as it will ensure that whatever memory could be release is released, before the function exits: public static void GC() { Runtime rt=Runtime.getRuntime(); long sm,mem=rt.freeMemory(); // *********************************** // * Must loop to ensure that gc() * // * is called and executed * // *********************************** mem=rt.freeMemory(); do { sm=mem;rt.gc(); mem=rt.freeMemory(); } while(mem>=sm); rt.runFinalization(); } If you call GC() occassionally, and compare the result obtained by calling GC() as frequently as you could, you should be able to appreciate the time taken by chain reaction. Hope my comment helps. Cheers Ng Say Teong
visad
archives: