[jdom-interest] SAXBuilder.build out of memory on 138KB data

Bradley S. Huffman hip at a.cs.okstate.edu
Tue Apr 1 14:08:56 PST 2003


Make sure your are running the latest code out of the CVS and not the
beta 8 jar.

Brad

"Steve Swett" writes:

> My document build step creates the document based upon the input stream
> of an HttpUrlConnection object. The size of the input stream, in this
> case, is about 138KB. I get an "out of memory" error.
> 
> When the input stream is about 40KB, this exact same code works just
> fine.
> 
> Here are the relevant parts of the code:
> 
> package aos320xml;
> 
> import java.io.*;
> import java.net.*;
> import java.util.*;
> import javax.xml.parsers.*; // XML library
> import org.jdom.*; // JDOM library
> import org.jdom.input.SAXBuilder; // JDOM library
> import org.xml.sax.*; // SAX library
> import org.apache.xerces.parsers.*; // XERCES library
> 
> public class AOS320xml {
> 
> public URL url;
> public HttpURLConnection connection;
> SAXBuilder builder = new SAXBuilder();
> 
> ...
> 
> try {
> 
> connection = (HttpURLConnection) url.openConnection();
> connection.setRequestMethod("POST");
> connection.setDoOutput(true);
> PrintWriter out = new PrintWriter(connection.getOutputStream());
> 
> // encode the message
> String myFunction =
> "Function="+URLEncoder.encode("GetStudentNames","UTF-8");
> 
> // send the encoded message
> out.print(EncodedMessage);
> out.close();
> 
> // get the XML response
> 
> System.out.println("Before build doc");
> // Following statement causes "out of memory error" when running for
> // all students.
> Document doc = builder.build(connection.getInputStream());
> System.out.println("After build doc");
> 
> ...
> 
> 
> Any ideas why I'm running out of memory? Solution?



More information about the jdom-interest mailing list