DOMParser memory leaks

B

byoder

I have implemented a parser pool (that is using the DOMParser via
DocumentBuilder and DocumentBuilderFactory) java 1.4.2 and it seems to
me that based on the memory profile that DOMParser was not meant to be
pooled and leaks memory (int[] variables are not cleaned up).

My pool is using the DocumentBuilder API to get the parser instance
and then caching that in the pool. There is no "reset" method, which
was introduced in java 1.5 and that indicates that it should be called
to "allow the reuse of existing DocumentBuilders" - but this method
doesn't exist in 1.4.2.

So is this a known limitation in 1.4.2 or has anyone else had issues
with memory leak "OutOfMemory" errors when using parser pools?

Thanks,

-BY
 
M

Mike Schilling

I have implemented a parser pool (that is using the DOMParser via
DocumentBuilder and DocumentBuilderFactory) java 1.4.2 and it seems
to
me that based on the memory profile that DOMParser was not meant to
be
pooled and leaks memory (int[] variables are not cleaned up).

My pool is using the DocumentBuilder API to get the parser instance
and then caching that in the pool.

Don't do that. Seriously, there's no real advantage in it, and you
can see the disadvantages.
 
B

byoder

I have implemented a parser pool (that is using the DOMParser via
DocumentBuilder and DocumentBuilderFactory) java 1.4.2 and it seems
to
me that based on the memory profile that DOMParser was not meant to
be
pooled and leaks memory (int[] variables are not cleaned up).
My pool is using the DocumentBuilder API to get the parser instance
and then caching that in the pool.

Don't do that.  Seriously, there's no real advantage in it, and you
can see the disadvantages.

At this point I am inclined to agree with you. When I started the
DOMParser pool it actually did appear to improve performance (based on
my memory profiler and use case), but if it leaks memory then it is
not a viable option. The most frustrating thing is the lack of
documentation on this (xerces or apache) and that it doesn't clearly
say if the class cannot be shared by multiple threads and/or reused.
Thanks for the advice.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,058
Latest member
QQXCharlot

Latest Threads

Top