Skip to content

Commit

Permalink
[DS-773] Reduce memory retained by objects with finalizers
Browse files Browse the repository at this point in the history
git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@5915 9c30dcfa-912a-0410-8fc2-9e0234be79fd
  • Loading branch information
grahamtriggs committed Dec 2, 2010
1 parent 687c560 commit b6339c3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
2 changes: 2 additions & 0 deletions dspace-api/src/main/java/org/dspace/core/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ public void complete() throws SQLException
// Free the connection
DatabaseManager.freeConnection(connection);
connection = null;
clearCache();
}
}

Expand Down Expand Up @@ -430,6 +431,7 @@ public void abort()
}
connection = null;
events = null;
clearCache();
}
}

Expand Down
32 changes: 20 additions & 12 deletions dspace-api/src/main/java/org/dspace/search/DSQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -446,18 +446,26 @@ protected static synchronized IndexSearcher getSearcher(Context c)
{
// So, open a new searcher
lastModified = IndexReader.getCurrentVersion(indexDir);
searcher = new IndexSearcher(indexDir){
/*
* TODO: Has Lucene fixed this bug yet?
* Lucene doesn't release read locks in
* windows properly on finalize. Our hack
* extend IndexSearcher to force close().
*/
protected void finalize() throws Throwable {
this.close();
super.finalize();
}
};
String osName = System.getProperty("os.name");
if (osName != null && osName.toLowerCase().contains("windows"))
{
searcher = new IndexSearcher(indexDir){
/*
* TODO: Has Lucene fixed this bug yet?
* Lucene doesn't release read locks in
* windows properly on finalize. Our hack
* extend IndexSearcher to force close().
*/
protected void finalize() throws Throwable {
this.close();
super.finalize();
}
};
}
else
{
searcher = new IndexSearcher(indexDir);
}
}

return searcher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,5 +242,7 @@ public void close()
catch (SQLException sqle)
{
}

columnNames = null;
}
}

0 comments on commit b6339c3

Please sign in to comment.