[jdom-interest] Memory problems

Pramodh Peddi peddip at contextmedia.com
Mon Dec 29 13:48:48 PST 2003


Hi,
I am using JDOM for XML processing. I use SAXBuilder. I am having memory problems when it deals with huge documents (like 10MB), even though it is using SAXBuidler. It throws OutOfMemoryError when I try to build a 8MB document.
I assume it does not keep the whole tree in memory if I use SAXBuilder. Does it? If what I assume is right, why is it running out of memory while building the doc of 8MB xml? 8MB should not be enough to make fail because of memory problems. right?

This is how I build a document:
****************************************************************************************************
    public Document getDocumentfromString(String xmlString)
        throws JDOMException, IOException {
        Document schemaDoc = null;
        SAXBuilder builder = new SAXBuilder(false);
        String resultingXML = null;
        byte[] xmlBytes = null;

        try {
            //get the UTF 8 encoded bytes
            xmlBytes = xmlString.getBytes("UTF8");
            schemaDoc = builder.build(new ByteArrayInputStream(xmlBytes));
        } catch (UnsupportedEncodingException usee) {
            //   system does not support UTF-8 encoding. use default encoding   
            schemaDoc = builder.build(new StringReader(xmlString));
        }

        return schemaDoc;
    }
*****************************************************************************************************

Am I doing anything wrong to make it fail while building a 8MB doc?

Do you think using JAXP API (again, using SAX) is better memory wise?

Any help would be greatly appreciated!

Thanks,

Pramodh.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20031229/adf26b31/attachment.htm


More information about the jdom-interest mailing list