[jdom-interest] SAXBuilder.build out of memory on 138KB data
Steve Swett
swett at bcswebsite.com
Tue Apr 1 15:43:53 PST 2003
I downloaded and built the latest code out of the CVS, and I still
experience the "out of memory" problem. I separated the code, as below,
a tiny bit to trace it just a touch further:
System.out.println("Before get input stream");
InputStream myInputStream = connection.getInputStream();
System.out.println("Before build doc");
// Following statement causes "out of memory error" when running
for
// all students.
Document doc = builder.build( new InputStreamReader(myInputStream)
);
System.out.println("After build doc");
There is no memory problem on the "connection.getInputStream()" step.
It happens on the "builder.build" step.
I've saved my "getInputStream()" data to a file so that you can see the
contents/format of the XML data. Again, this works fine when there is
about one third as much data in this file. The saved data file can be
accessed from this link:
http://www.bcswebsite.com/Timpanogos/allstudentsxml.txt
I'm on Windows XP Pro with JDK 1.4.1_01.
Any other thoughts?
Thanks.
-----Original Message-----
From: Bradley S. Huffman [mailto:hip at a.cs.okstate.edu]
Sent: Tuesday, April 01, 2003 5:09 PM
To: Steve Swett
Cc: jdom-interest at jdom.org
Subject: Re: [jdom-interest] SAXBuilder.build out of memory on 138KB
data
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