we need to transform a large xml (50 MB) to a flat file. Our java program throws out of memory exception. any pointer will be helpful in this regard.
First, increase the maximum heap size with the command-line parameter. For example:
java ... -ms64m -mx128m ... (use 64-128 megs for the JVM)
If the problem still occurs, increase the heap size again. Still a problem? Try to optimize code radically. Last resort? Buy more memory.
Consider trying to "localize" the XSLT template. Try to make a template that can be applied to a small portion of the XML file rather than processing it all in one giant chunk. Even if you use SAX, Xalan will load the whole thing into the memory before processing it. In my expirience it is rare for every part of the template to require access to the whole document.