Bug #1481
closedMemory "leak" caused by ThreadLocal converter cache
100%
Description
Saxon maintains a cache of "converter" objects for converting/casting values from type A to type B: if the same conversion is performed repeatedly, this avoids complex navigation of the type hierarchy to decide what to do. The cache is an LRU cache held in ThreadLocal. Because the converter objects contain a reference to a Configuration, in the case where many Configuration objects are created they can end up not being garbage collected. The fact that the cache is LRU should avoid this in theory, but in practice it seems the number of ThreadLocal objects on the heap can greatly exceed the number of threads, leading to a large number of Configuration objects, and their associated resources such as the namePool and TypeHierarchy, being locked down in memory.
Related issues
Updated by Michael Kay about 12 years ago
- Status changed from New to Resolved
A patch for the 9.4 branch is being committed. The effect of the patch is to replace the thread-local LRU cache for converter objects with a shared thread-safe cache held by the ConversionRules object, that is, effectively, a cache owned by the Configuration.
(The 9.5 version of this fix additionally ensures that some requests for converters that currently bypass the cache no longer do so.)
Updated by Michael Kay almost 12 years ago
- Status changed from Resolved to Closed
- % Done changed from 0 to 100
- Fixed in version set to 9.4.0.4
Please register to edit this issue