Re: OutOfMemoryError when using SAX to process an XML document

Discussion in 'Java' started by Robert Olofsson, Jul 2, 2003.

  1. : I was wondering if anyone has encountered an OutOfMemoryError while using
    : SAX to parse an XML file and if so, how did you resolve the problem? The
    : file itself is quite large (about 29717K) and I've tried increasing the swap
    : space on the JVM memory to 1GB, but it still hangs after a certain point.

    Seems like your leaking memory. When parsing documents with dom4j using
    _DOM_ memory seems to be around 6 times the file size (50MB file=>300MB
    memory usage).
    With SAX I would expect that you dont use very much memory unless you build
    huge data structures.

    Grab a profiler and find out what references you keep around.

    How did you increase the jvm memory? with the -Xmx1024m flag or?

    /robo
    Robert Olofsson, Jul 2, 2003
    #1
    1. Advertising

  2. "Robert Olofsson" <> wrote in message
    news:bdttg8$5bg$...
    > Seems like your leaking memory. When parsing documents with dom4j using
    > _DOM_ memory seems to be around 6 times the file size (50MB file=>300MB
    > memory usage). With SAX I would expect that you dont use very much memory

    unless you build
    > huge data structures.


    I'm not really creating a huge data structure - just a simple class with
    Strings references and one ArrayList object - I call its toString method in
    the endElement method, so there isn't really anything hanging around.

    > Grab a profiler and find out what references you keep around.


    Any profiler you recommend? I'm using Eclipse.

    > How did you increase the jvm memory? with the -Xmx1024m flag or?


    Yes, with the -Xms512m -Xmx1024m flag.

    > /robo

    Thanks for your suggestions - I'm googling for an Eclipse profiler as I
    write this.
    Sunitha Kumar, Jul 2, 2003
    #2
    1. Advertising

  3. Sunitha Kumar () wrote:
    : I'm not really creating a huge data structure - just a simple class with
    : Strings references and one ArrayList object - I call its toString method in
    : the endElement method, so there isn't really anything hanging around.

    : > Grab a profiler and find out what references you keep around.
    : Any profiler you recommend? I'm using Eclipse.

    Well, I do develop an open source profiler called jmp. It works nice
    for me:
    http://www.khelekore.org/jmp/

    On sourceforge you will also find a few other jvmpi-based free profilers.
    mjp, http://mjp.sourceforge.net/, may work for you, I have not
    used it myself

    I also know that there are a few eclipse plugins for profiling available
    but havent really tried any since I use emacs (and sometimes vi).

    /robo
    Robert Olofsson, Jul 2, 2003
    #3
  4. > Well, I do develop an open source profiler called jmp. It works nice
    > for me:
    > http://www.khelekore.org/jmp/
    > On sourceforge you will also find a few other jvmpi-based free profilers.
    > mjp, http://mjp.sourceforge.net/, may work for you, I have not
    > used it myself
    >
    > I also know that there are a few eclipse plugins for profiling available
    > but havent really tried any since I use emacs (and sometimes vi).


    Robo, thanks for your advice - I've never used a profiler before, but I'll
    make sure to try your implementation out.: )
    BTW, for the record, it isn't a memory leak - I tried parsing the document,
    without the callbacks and found to my dismay that the SAX parser wasn't able
    to parse the document completely. In the process, I ran across an altogether
    new error:

    Error: org.xml.sax.SAXParseException: Parser has reached the entity
    expansion limit "64,000" set by the Application.

    A google search turned this document up:
    http://java.sun.com/webservices/docs/1.2/jaxp/ReleaseNotes.html#schema-limitations,
    but I'm not sure if changing the entity expansion limit will really do
    anything for me.

    Any suggestions, comments, advice?

    Sunitha/.
    Sunitha Kumar, Jul 3, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Per Magnus L?vold

    SAX parser ignores part of XML document

    Per Magnus L?vold, Nov 19, 2004, in forum: Java
    Replies:
    1
    Views:
    468
    John C. Bollinger
    Nov 19, 2004
  2. Jari Kujansuu
    Replies:
    2
    Views:
    1,003
    Jari Kujansuu
    Sep 30, 2003
  3. Tony Prichard
    Replies:
    0
    Views:
    723
    Tony Prichard
    Dec 12, 2003
  4. Marcin Cenkier
    Replies:
    2
    Views:
    6,235
    Marcin Cenkier
    Jan 19, 2006
  5. Erik Wasser
    Replies:
    5
    Views:
    452
    Peter J. Holzer
    Mar 5, 2006
Loading...

Share This Page