[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Out of memory error with XML and Java ResultSet


java out of memory error
With 70MB of output text, writing to a StringBuffer is going to be 
awkward at best. :-) Try changing your code to write to a temporary 
file, then just reread the file for whatever processing you want to do 
(which hopefully doesn't involve building a DOM or such).

I'd think the null transform to a StreamResult would just write the 
text, but I'm not sure. If you still run into problems after changing 
the code to output to a file you may need to use a different way of writing.

  - Dennis

Brown, Jason B. wrote:

>Dennis,
>
>One row of XML text is approximately 230 characters, including tag name
>and attribute specifiers.  I thought my implementation was streaming the
>information to the destination.  Here is the code for the XML writing
>class:
>
>	/**
>	 * Constructor
>	 */
>	public CisXmlWriterSAX(StreamResult xmlOutput,
>	                       String dtdFile) {
>		try {
>			transFact = (SAXTransformerFactory)
>SAXTransformerFactory.newInstance();
>			
>			handler = transFact.newTransformerHandler();
>			
>			serializer = handler.getTransformer();
>
>			serializer.setOutputProperty(OutputKeys.METHOD,
>"XML");
>			serializer.setOutputProperty(OutputKeys.INDENT,
>"yes");
>	
>serializer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, dtdFile);
>	
>serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
>			
>			handler.setResult(xmlOutput);
>
>/*
>Old code ----------
>			of = new OutputFormat(outputType,
>outputEncoding, true);
>			of.setIndent(1);
>			of.setIndenting(true);
>			of.setDoctype(null, dtdFile);
>
>			// Might be able to use StringWriter
>			serializer = new XMLSerializer(xmlOutput, of);
>
>			handler = serializer.asContentHandler();
>Old code ----------
>*/
>
>		} 
>        catch (TransformerConfigurationException tce) {
>      	    CDebug.print("Error in CisXmlWriterSAX: " + tce.toString());
>			if (CDebug.isDebug()) {
>				tce.printStackTrace();
>			}
>        }
>
>	}
>
>If I stream the information directly to the destination, then that means
>the destination would have to receive the information and process it.
>Currently, I am saving the information in a StringBuffer object which
>gets returned to the calling object.  But, that is still storing the
>information in memory, which can be costly.
>
>Thanks.
>
>Jason B. Brown
>CIS IS Claims
>215-241-4609
>x2-4609 (internal), 11th Floor
>mailto:jason.b.brown@i...
>  
>
>  
>


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.