You can't really _force_ the JVM to perform the GC and clean up the heap, although you can _suggest_ it via System.gc()
You can try playing with this: private static long gc() { long freeMemBefore = Runtime.getRuntime().freeMemory(); System.out.println("Free Memory Before: " + freeMemBefore); System.gc(); try { Thread.sleep(1000); System.runFinalization(); Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } System.gc(); long freeMemAfter = Runtime.getRuntime().freeMemory(); System.out.println("Total Memory : " + Runtime.getRuntime().totalMemory()); System.out.println("Max Memory : " + Runtime.getRuntime().maxMemory()); System.out.println("Free Memory After : " + freeMemAfter); return freeMemBefore-freeMemAfter; } Otis --- "Aigner, Thomas" <[EMAIL PROTECTED]> wrote: > Please forgive my jumping on this thread, but I have a similar issue. > I > have a server process on Linux that creates the java process (java > -Xms256m -Xmx512m -jar Suchmaschine.jar). The problem is that after > the > processing is done, the memory is retained. Is there a collection > argument that would shrink the java memory pool back down to the min? > > Thanks, > Tom > > -----Original Message----- > From: Otis Gospodnetic [mailto:[EMAIL PROTECTED] > Sent: Thursday, August 11, 2005 11:15 AM > To: java-user@lucene.apache.org > Subject: Re: OutOfMemoryError on addIndexes() > > > > Is -Xmx case sensitive? Should it be 1000m instead of 1000M? > Not > > > sure. > > > > > > > I'am starting with: > > java -Xms256M -Xmx512M -jar Suchmaschine.jar > > And if you look at the size of your JVM, does it really use all 512 > MB? > If it does not, maybe you can try this: > > java -Xms256m -Xmx512m -jar Suchmaschine.jar > > If that doesn't help, it would be good to run this under a profiler > and > see what eats your memory. > > Otis > P.S. > I recall reading that using the same amount for Xms and Xmx results > in > better performance. Also, consider using -server option (Hotspot), > if > you are using Sun's JVM. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]