users@jaxb.java.net

Re: How the caching is done in JAXB

From: Aleksei Valikov <valikov_at_gmx.net>
Date: Fri, 28 Nov 2008 08:05:30 +0100

Hi.

> Iam using jaxb version 2.1.8. When i pass a huge file 250MB for JAXB
> Marshaller it is throwing "out of memory error". So i want to know how the
> JAXB is implementing Cache. Whether it is using Memory cache (Map) or Disk
> level cache (Ehcache). If JAXB is using Ehcache, can we configure it to
> suit our needs. Can anyboly please provide a solution to my problem with out
> increasing the Java Heap size.
>
> Any help is much appreciated.

If you pass 250MB XML to JAXB unmarshaller, then you're getting the
object structure of about the same size back. Surely you'll get
problems with memory. This has almost nothing to do with caching,
using ehcache and so on won't directly help.

The right approach for your problem depends on how the data is
structured. If you just have a great nuber of independent elements
like here:

<root>
  <element index="0">...</element>
  ...
  <element index="1000000">...</element>
</root>

then you could try StAX/JAXB combination as described here:

http://www.javarants.com/C1464297901/E20060501083853/index.html

See also here: https://jaxb.dev.java.net/guide/Dealing_with_large_documents.html

If you elements are linked with ID/IDREF attributes, you may also need
to provide a custom IDResolver.

Bye.
/lexi