xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
- From: "Marcus Downing" <marcus AT minotaur.it>
- To: xom-interest AT lists.ibiblio.org
- Subject: [XOM-interest] XOM memory usage
- Date: Wed, 26 Sep 2007 14:24:12 +0100
I've successfully used XOM on many reasonable-sized documents. Now I
need to parse a 10Mb xml document, and the memory usage is just too
much.
I manage to process about 90% of the elements before hitting an
OutOfMemoryError, which suggests that something is a being assigned
and held onto as each element is parsed. Is there anything I should be
doing to minimise the memory use or release elements which are no
longer needed?
A simplified version of my code, with almost everything removed for clarity:
// document
FileInputStream in = new FileInputStream(file);
Builder builder = new Builder();
Document document = builder.build(in, "");
Element rootElement = document.getRootElement();
Element resultSetElement =
rootElement.getFirstChildElement("RESULTSET",
"http://www.filemaker.com/fmpxmlresult");
// column headings
Element metaDataElement = rootElement.getFirstChildElement("METADATA",
"http://www.filemaker.com/fmpxmlresult");
Elements fieldElements = metaDataElement.getChildElements("FIELD",
"http://www.filemaker.com/fmpxmlresult");
fieldNames = new String[fieldElements.size()];
for (int i = 0, n = fieldElements.size(); i < n; i++) {
Element fieldElement = fieldElements.get(i);
fieldNames[i] = fieldElement.getAttributeValue("NAME");
}
// data
Elements rows = resultSetElement.getChildElements("ROW",
"http://www.filemaker.com/fmpxmlresult");
int size = rows.size();
for (int i = 0; i < size; i++) {
Element rowElement = rows.get(i);
parseRow(rowElement);
}
--
Marcus Downing
-
[XOM-interest] XOM memory usage,
Marcus Downing, 09/26/2007
- Re: [XOM-interest] XOM memory usage, Elliotte Harold, 09/26/2007
Archive powered by MHonArc 2.6.24.