Issue Details (XML | Word | Printable)

Key: LUCENE-1186
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Michael McCandless
Reporter: Christian Kohlschütter
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Lucene - Java

[PATCH] Clear ThreadLocal instances in close()

Created: 22/Feb/08 10:54 AM   Updated: 25/Sep/09 04:23 PM
Return to search
Component/s: None
Affects Version/s: 2.3, 2.3.1, 2.4
Fix Version/s: 2.4.1, 2.9

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works LUCENE-1186-SegmentReader.patch 2008-02-22 10:55 AM Christian Kohlschütter 0.3 kB
Text File Licensed for inclusion in ASF works LUCENE-1186.patch 2009-02-27 12:05 PM Michael McCandless 3 kB
Text File Licensed for inclusion in ASF works LUCENE-1186.patch 2009-02-27 11:53 AM Michael McCandless 3 kB
Environment: any

Lucene Fields: New, Patch Available
Resolution Date: 02/Mar/09 04:44 PM


 Description  « Hide
As already found out in LUCENE-436, there seems to be a garbage collection problem with ThreadLocals at certain constellations, resulting in an OutOfMemoryError.
The resolution there was to remove the reference to the ThreadLocal value when calling the close() method of the affected classes (see FieldsReader and TermInfosReader).
For Java < 5.0, this can effectively be done by calling threadLocal.set(null); for Java >= 5.0, we would call threadLocal.remove()

Analogously, this should be done in any class which creates ThreadLocal values

Right now, two classes of the core API make use of ThreadLocals, but do not properly remove their references to the ThreadLocal value
1. org.apache.lucene.index.SegmentReader
2. org.apache.lucene.analysis.Analyzer

For SegmentReader, I have attached a simple patch.
For Analyzer, there currently is no patch because Analyzer does not provide a close() method (future to-do?)



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
No work has yet been logged on this issue.