Is XML the right technology to transfer files of the order of 30 mb. I am designing an app, that has to transform a 30 mb text file to an XML file. And I am running into all kind of memory issues. I tried toying with the jvm heap size by Xmx67108864. But it doesn't help either. I tried a DOM parser and then a SAX parser and everthing failed. So, what is the solution. Thanks Chirag
Generally XML should be used for small amounts of data, with references to large (binary for example) data. XML tends to be very inefficient when compared to binary formats, and relies on the fact that modern machines are massivley powerful, and we dont often care about the use of a few exter processor cycles. If you genuinely have 30Meg of well formed XML text (rather than a large single piece of data in <data>data</data> tags of some kind) then perhaps you should split into multiple files and link them with references.
I am not surprised you are facing memory issues because 30MB is not by any means a size of a typical XML file. The parser performance degrades with the increase in size of the XML file. Among the parsers themselves, you will see SAX parsers perform quite well when compared with DOM parsers as they don't have to maintain an in-memory image of the XML tree. If your requirement is to deal with such large XML files, then think of writing a "feeder" framework that walks through big chunks of the input XML stream and feeds them to the parser. Ofcourse with such an additional layer, it may not be trivial to handle validation, cross references etc.
------------------ Ajith Kallambella M. Sun Certified Programmer for the Java�2 Platform. IBM Certified Developer - XML and Related Technologies, V1. Co-author of Java 2 Certification Passport
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).