Search code examples
javaxml-parsinggarbage-collectionxstream

XML Parsing throwing java.lang.OutOfMemoryError: GC overhead limit exceeded


I am parsing XML File of Size 2GB. For Parsing am using Xstream Library, Its wait for 5mins then it is throwing java.lang.OutOfMemoryError: GC overhead limit exceeded.

Can you provide solution to parse large amount of XML files. Can you provide alternatives to parse XML Files faster.

Update: I have done using JaxB+Stax parser to resolve performance and resolved java.lang.OutOfMemoryError: GC overhead limit exceeded exception.


Solution

  • You should go for a parser whihc wouldn't load the whole xml into memory.

    SAX or if you are interested in only a subset of xml then Stax.

    Even in those cases , your memory can be clogged up by the data you parse a nd populate into the data structure of your choice.

    You should take a look at the below answer How to Parse Big (50 GB) XML Files in Java