Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Appending at the end of an Xml file efficiently

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Tatu Saloranta <cowtowncoder AT yahoo.com>
  • To: Anvesh Vagiri <yahanvesh AT gmail.com>
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] Appending at the end of an Xml file efficiently
  • Date: Sat, 20 Jun 2009 09:13:13 -0700 (PDT)


--- On Sat, 6/20/09, Elliotte Harold <elharo AT ibiblio.org> wrote:

> Anvesh Vagiri<yahanvesh AT gmail.com>
> wrote:
> > hi,
> >
> > I am just a newbie to XOM, and i need to append nodes to an existing
> > xml file always at the end I used the code available here.
> >
> > http://marc.info/?l=xom-interest&m=117286293113470&w=2
> >
> > But unfortunately it gives Out of memory error in my java netbeans
> > when the file size increases more than just 10-15MB.
> >
>
> 1. Try running the code outside NetBeans.
> 2. Use a profiler to see where the memory is going, and if
> you have memory leak somewhere.

It is also possible that it's just because of default heap size (64M), and
typical expanse ratio of a tree model (3x - 5x) means that all memory is
getting used. If so, increasing heap size would overcome problem for this
case.

But if significantly bigger documents are to be handled, the usual solution
is to either process document sub-tree at a time (if it's record-based and
this is possible), or use a lower-level abstraction like streaming parser &
generator. This would be done by reading through existing document up until
addition point, copying content through, and then starting to add content
after this.
My personal favorite is StaxMate (http://staxmate.codehaus.org/Tutorial), but
I am bit biased.

-+ Tatu +-








Archive powered by MHonArc 2.6.24.

Top of Page