PAGE2GO2 HOME | INTERNET NEWS

LeighExchange - Free Advertising Network Stock Research at Internet Speed Need Money Easy and Quick?

Re: Get "java.lang.OutOfMemoryError" when Parsing an XML useing DOM

 List
Subject: Re: Get "java.lang.OutOfMemoryError" when Parsing an XML useing DOM
Poster: Lewlew@nospam.lewscanon.com
Date: Fri, 23 Mar 2007 16:43:29 -0500
Related Postings: 1 2 3 4 5 6 7 8 9 10 11 12
John W. Kennedy wrote:
> SAX won't necessarily be /faster/ [than DOM] -- it could be a lot slower. It
> depends on what you're doing.
>
> Are you page-thrashing? If so, than SAX is definitely a good idea.

Another way SAX can really speed things up is that you can use it to handle an entire XML document in a single pass without huge memory structures to build and traverse. Back when Java 1.2 first came out I was on a project that used Java and SAX to parse largish XML documents over the network and it ran like a bat out of heck. With modern network tech (gigabit LAN, ...), today's processors and the improvements in Java it would truly scream.

It sounds like the OP's DOM tree is too large to process efficiently. SAX, correctly used, would almost certainly create a huge speed improvement - like from 2 hours-infinite down to about a second or two, I would guess.

Like JWK said, it really depends on what you do with the parsed data. Additional I/O (writing the parsed data to a file or DBMS), large auxiliary memory structures and other factors could kill the speedup.

-- Lew

 

Page2Go2.com is not responsible for content of this message.