Search code examples
javaxmljaxb2

generating large xml using jaxb


I need to generate a big xml. I am currently using JAXB 2.0 .

The problem is if I keep all the objects in memory and generate the probability of running out of heap space is very high.

I would like to know the best approach on how to do this.

Thanks


Solution

  • You can use StAX to marshal the outer body of the XML, and then use JAXB to marshal the repeated objects without having to have them all in memory.

    See this thread: http://glassfish.10926.n7.nabble.com/Marshalling-Large-data-into-xml-td55636.html