Project

Profile

Help

Revision 9578830b

Added by Michael Kay almost 14 years ago

Fix bug 1925023 - reset() builder to avoid locking down documents in memory because of parser pool

View differences:

latest9.0/bj/net/sf/saxon/Configuration.java
1824 1824
        if (styleParserPool == null) {
1825 1825
            styleParserPool = new ArrayList(10);
1826 1826
        }
1827
        try {
1828
            // give things back to the garbage collecter
1829
            parser.setContentHandler(null);
1830
            parser.setEntityResolver(null);
1831
            parser.setDTDHandler(null);
1832
            parser.setErrorHandler(null);
1833
        } catch (Exception err) {
1834
            //
1835
        }
1827 1836
        styleParserPool.add(parser);
1828 1837
    }
1829 1838

  
......
2750 2759
        // Get the constructed document
2751 2760

  
2752 2761
        DocumentInfo newdoc = (DocumentInfo)b.getCurrentRoot();
2762
        b.reset();
2753 2763

  
2754 2764
        // If requested, close the input stream
2755 2765

  
latest9.0/bj/net/sf/saxon/Controller.java
1552 1552
                    ((AugmentedSource)source).close();
1553 1553
                }
1554 1554
                DocumentInfo doc = (DocumentInfo)sourceBuilder.getCurrentRoot();
1555
                sourceBuilder.reset();
1555 1556
                registerDocument(doc, source.getSystemId());
1556 1557
                startNode = doc;
1557 1558
            }
latest9.0/bj/net/sf/saxon/PreparedStylesheet.java
240 240
            sender.send(aug, commentStripper);
241 241
        }
242 242
        doc = (DocumentImpl)styleBuilder.getCurrentRoot();
243
        styleBuilder.reset();
243 244

  
244 245
        if (aug.isPleaseCloseAfterUse()) {
245 246
            aug.close();
latest9.0/bj/net/sf/saxon/event/Builder.java
207 207
        return currentRoot;
208 208
    }
209 209

  
210
   /**
211
     * Reset the builder to its initial state. The most important effect of calling this
212
     * method (implemented in subclasses) is to release any links to the constructed document
213
     * tree, allowing the memory occupied by the tree to released by the garbage collector even
214
     * if the Builder is still in memory. This can happen because the Builder is referenced from a
215
     * parser in the Configuration's parser pool.
216
     */
217

  
218
    public void reset() {
219
        pipe = null;
220
        config = null;
221
        namePool = null;
222
        systemId = null;
223
        baseURI = null;
224
        currentRoot = null;
225
        lineNumbering = false;
226
        started = false;
227
        timing = false;
228
        open = false;
229
    }
230

  
210 231
    /**
211 232
     * Static method to build a document from any kind of Source object. If the source
212 233
     * is already in the form of a tree, it is wrapped as required.
......
275 296
                throw XPathException.makeXPathException(err);
276 297
            }
277 298
            start = b.getCurrentRoot();
299
            b.reset();
278 300
        }
279 301
        return start;
280 302
    }
latest9.0/bj/net/sf/saxon/functions/Document.java
361 361
                }
362 362
                new Sender(b.getPipelineConfiguration()).send(source, s);
363 363
                newdoc = (DocumentInfo)b.getCurrentRoot();
364
                b.reset();
364 365
                if (source instanceof AugmentedSource && ((AugmentedSource)source).isPleaseCloseAfterUse()) {
365 366
                    ((AugmentedSource)source).close();
366 367
                }
latest9.0/bj/net/sf/saxon/tinytree/TinyBuilder.java
167 167

  
168 168
    }
169 169

  
170
    public void reset() {
171
        super.reset();
172
        tree = null;
173
        currentDepth = 0;
174
        nodeNr = 0;
175
        ended = false;
176
        sizeParameters = null;
177
    }
178

  
170 179
    public void close() throws XPathException {
171 180
        //System.err.println("Tree.close " + tree + " size=" + tree.numberOfNodes);
172 181
        tree.addNode(Type.STOPPER, 0, 0, 0, -1);
latest9.0/bj/net/sf/saxon/tree/TreeBuilder.java
124 124

  
125 125
    }
126 126

  
127
    public void reset() {
128
        super.reset();
129
        currentNode = null;
130
        nodeFactory = null;
131
        depth = 0;
132
        nextNodeNumber = 1;
133
    }
134

  
127 135
    /**
128 136
    * Notify the start of an element
129 137
    */

Also available in: Unified diff