<html>
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 10 (filtered)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:Verdana;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {font-family:Arial;
        color:windowtext;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style>
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><font size=2 color=black face=Verdana><span
style='font-size:10.0pt;font-family:Verdana;color:black'>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.<br>
<br>
When the input stream is about 40KB, this exact same code works just fine.<br>
<br>
Here are the relevant parts of the code:<br>
<br>
package aos320xml;<br>
<br>
import java.io.*;<br>
import java.net.*;<br>
import java.util.*;<br>
import javax.xml.parsers.*; // XML library<br>
import org.jdom.*; // JDOM library<br>
import org.jdom.input.SAXBuilder; // JDOM library<br>
import org.xml.sax.*; // SAX library<br>
import org.apache.xerces.parsers.*; // XERCES library<br>
<br>
public class AOS320xml {<br>
<br>
public URL url;<br>
public HttpURLConnection connection;<br>
SAXBuilder builder = new SAXBuilder();<br>
<br>
...<br>
<br>
try {<br>
<br>
connection = (HttpURLConnection) url.openConnection();<br>
connection.setRequestMethod("POST");<br>
connection.setDoOutput(true);<br>
PrintWriter out = new PrintWriter(connection.getOutputStream());<br>
<br>
// encode the message<br>
String myFunction = "Function="+URLEncoder.encode("GetStudentNames","UTF-8");<br>
<br>
// send the encoded message<br>
out.print(EncodedMessage);<br>
out.close();<br>
<br>
// get the XML response<br>
<br>
System.out.println("Before build doc");<br>
// Following statement causes "out of memory error" when running for<br>
// all students.<br>
Document doc = builder.build(connection.getInputStream());<br>
System.out.println("After build doc");<br>
<br>
...<br>
<br>
<br>
Any ideas why I'm running out of memory? Solution?</span></font></p>
</div>
</body>
</html>