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

Steve Swett swett at bcswebsite.com
Tue Apr 1 13:03:35 PST 2003


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?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20030401/7316191b/attachment.htm


More information about the jdom-interest mailing list