#353 Resource leak with multiple Configurations

v8.4
closed
5
2012-10-08
2005-04-28
Michael Kay
No

When multiple Configuration objects are created without
reloading Saxon, a resource leak can occur. The system
maintains a static cache of SequenceType objects so
that these can be reused. However, some SequenceType
objects contain references to Configuration objects,
meaning that this static cache constantly expands, and
also keeps the Configuration objects and things linked
to the Configurations locked in memory.

The SequenceType cache can be disabled for all but
built-in atomic types (which are safe to cache) by the
following patch:

At line 153 in net.sf.saxon.value.SequenceType, change
the start of the method to read:

public static SequenceType

makeSequenceType(ItemType primaryType, int cardinality) {

    if (!(primaryType instanceof BuiltInAtomicType)) {
        return new SequenceType(primaryType,

cardinality);
}

MK

Discussion