Re: java.lang.OutofMemoryError

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          *
      // ***********************************
      do {
      } while(mem>=sm);
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. 


Ng Say Teong