OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] Out of memory error with XML and Java ResultSet

[ Lists Home | Date Index | Thread Index ]

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@ibx.com
>  
>
>  
>





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS