lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <hossman_luc...@fucit.org>
Subject Re: how to free memory after index ist build.
Date Tue, 02 Aug 2005 16:19:42 GMT

: 2) I don't see the code to close your statement, connection, and
: ResultSet.  Those typically go to a finally block.

I'm 85% sure that's the memory leak right there... in absence of a
good memory profiler, have you tried commenting out all of the Lucene
related code, to make sure that your basic DB Data retrieval code doesn't
leak memory?

i'm guessing that without the Lucene code, it won't run out of RAM as fast
(because their won't be a RAMDirectory index taking up space) but you
should still see your free memory steadily decrease.


:     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;
:     }



-Hoss


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message