lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Richard Krenek <richard.kre...@gmail.com>
Subject Re: how to free memory after index ist build.
Date Wed, 03 Aug 2005 13:30:02 GMT
Try doing that in reverse order:

rs.close();
rs = null;
stmnt.close();
stmnt = null;
conn.close();
conn = null;

I usual do one more step also, just to be safe.

try {rs.close();} catch (Exception ignore) {}
rs = null;
try {stmnt.close();} catch (Exception ignore) {}
stmnt = null;
try {conn.close();} catch (Exception ignore) {}
conn = null;

On 8/3/05, Jan Philipp Seng <jp.seng@gmx.de> wrote:
> > : 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.
> 
> Thank you Hoos,
> 
> I left some of my code out to make it compact. There is a finally-block that
> does rigth this.
> But you are completely rigth. I commented out all Lucene related code and
> the free memory decreases every indexing run. I close the connection, but
> this does not free the memory. Do you have another hint for me what I can do
> against the memory leak in the connector to the mySQL-database? I am using
> mysql-connector-java-3.1.10-bin.jar.
> 
> Constructor: inits the members:
>         Connection conn
>   Statement stmt
>   ResultSet rs
> finally block:
>         conn.close();
>         conn = null;
>   stmt.close();
>   stmt = null;
>   rs.close();
>   rs = null;
> 
> Bye for now.
> 
> Jan
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
> 
>

---------------------------------------------------------------------
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