lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Newson (JIRA)" <j...@apache.org>
Subject [jira] Commented: (LUCENE-1715) DirectoryIndexReader finalize() holding TermInfosReader longer than necessary
Date Tue, 23 Jun 2009 17:42:07 GMT

    [ https://issues.apache.org/jira/browse/LUCENE-1715?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12723203#action_12723203
] 

Robert Newson commented on LUCENE-1715:
---------------------------------------

I wonder if it's also worth examining the (very few) other places that have finalize()?

The mere presence of a finalize() method triggers different handling by the garbage collector.
 Since all remaining finalize() methods appear to close resources that should have been closed
explicitly, the same principle applies for those as for the resolution of LUCENE-1715?

src/java/org/apache/lucene/store/SimpleFSDirectory.java:      protected void finalize() throws
Throwable {
src/java/org/apache/lucene/store/SimpleFSDirectory.java-        try {
src/java/org/apache/lucene/store/SimpleFSDirectory.java-          close();
src/java/org/apache/lucene/store/SimpleFSDirectory.java-        } finally {
src/java/org/apache/lucene/store/SimpleFSDirectory.java:          super.finalize();
src/java/org/apache/lucene/store/SimpleFSDirectory.java-        }
src/java/org/apache/lucene/store/SimpleFSDirectory.java-      }
src/java/org/apache/lucene/store/SimpleFSDirectory.java-    }

src/java/org/apache/lucene/store/NativeFSLockFactory.java:  public void finalize() throws
Throwable {
src/java/org/apache/lucene/store/NativeFSLockFactory.java-    try {
src/java/org/apache/lucene/store/NativeFSLockFactory.java-      if (isLocked()) {
src/java/org/apache/lucene/store/NativeFSLockFactory.java-        release();
src/java/org/apache/lucene/store/NativeFSLockFactory.java-      }
src/java/org/apache/lucene/store/NativeFSLockFactory.java-    } finally {
src/java/org/apache/lucene/store/NativeFSLockFactory.java:      super.finalize();
src/java/org/apache/lucene/store/NativeFSLockFactory.java-    }
src/java/org/apache/lucene/store/NativeFSLockFactory.java-  }
src/java/org/apache/lucene/store/NativeFSLockFactory.java-}


src/java/org/apache/lucene/index/IndexWriter.java-  /** Release the write lock, if needed.
*/
src/java/org/apache/lucene/index/IndexWriter.java:  protected void finalize() throws Throwable
{
src/java/org/apache/lucene/index/IndexWriter.java-    try {
src/java/org/apache/lucene/index/IndexWriter.java-      if (writeLock != null) {
src/java/org/apache/lucene/index/IndexWriter.java-        writeLock.release();           
            // release write lock
src/java/org/apache/lucene/index/IndexWriter.java-        writeLock = null;
src/java/org/apache/lucene/index/IndexWriter.java-      }
src/java/org/apache/lucene/index/IndexWriter.java-    } finally {
src/java/org/apache/lucene/index/IndexWriter.java:      super.finalize();
src/java/org/apache/lucene/index/IndexWriter.java-    }
src/java/org/apache/lucene/index/IndexWriter.java-  }

src/java/org/apache/lucene/index/DirectoryReader.java-  /** Release the write lock, if needed.
*/
src/java/org/apache/lucene/index/DirectoryReader.java:  protected void finalize() throws Throwable
{
src/java/org/apache/lucene/index/DirectoryReader.java-    try {
src/java/org/apache/lucene/index/DirectoryReader.java-      if (writeLock != null) {
src/java/org/apache/lucene/index/DirectoryReader.java-        writeLock.release();       
                // release write lock
src/java/org/apache/lucene/index/DirectoryReader.java-        writeLock = null;
src/java/org/apache/lucene/index/DirectoryReader.java-      }
src/java/org/apache/lucene/index/DirectoryReader.java-    } finally {
src/java/org/apache/lucene/index/DirectoryReader.java:      super.finalize();
src/java/org/apache/lucene/index/DirectoryReader.java-    }
src/java/org/apache/lucene/index/DirectoryReader.java-  }


> DirectoryIndexReader finalize() holding TermInfosReader longer than necessary
> -----------------------------------------------------------------------------
>
>                 Key: LUCENE-1715
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1715
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Index
>    Affects Versions: 2.4.1
>         Environment: Sun JDK 6 update 12 64-bit, Debian Lenny
>            Reporter: Brian Groose
>            Assignee: Michael McCandless
>             Fix For: 2.9
>
>
> DirectoryIndexReader has a finalize method, which causes the JDK to keep a reference
to the object until it can be finalized.  SegmentReader and MultiSegmentReader are subclasses
that contain references to, potentially, hundreds of megabytes of cached data in a TermInfosReader.
> Some options would be removing finalize() from DirectoryIndexReader (it releases a write
lock at the moment) or possibly nulling out references in various close() and doClose() methods
throughout the class hierarchy so that the finalizable object doesn't references the Term
arrays.
> Original mailing list message:
> http://mail-archives.apache.org/mod_mbox/lucene-java-user/200906.mbox/%3C7A5CB4A7BBCE0C40B81C5145C326C31301A62971@NUMEVP06.na.imtn.com%3E

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


Mime
View raw message