ArchiveOrangemail archive

xerces-j-user.xml.apache.org


(List home) (Recent threads) (48 other Apache XML lists)

Subscription Options

  • RSS or Atom: Read-only subscription using a browser or aggregator. This is the recommended way if you don't need to send messages to the list. You can learn more about feed syndication and clients here.
  • Conventional: All messages are delivered to your mail address, and you can reply. To subscribe, send an email to the list's subscribe (we seem to have lost it) address with "subscribe" in the subject line.
  • This list contains about 9,514 messages, beginning Mar 2001
  • This list doesn't seem to be active
Report the Spam
This button sends a spam report to the moderator. Please use it sparingly. For other removal requests, read this.
Are you sure? yes no

Serialization StackOverflowError

Ad
Michael Ryan Bannon 1068141041Thu, 06 Nov 2003 17:50:41 +0000 (UTC)
Hello,

Forgive me if this has been mentioned before in another thread...

I am running into a StackOverflowError when attempting to serialize a large XML document (10000+ nodes, with a height of 10000).
I have the following method:

 private static String serialize(Document doc) {
Michael Glavassevich 1068145594Thu, 06 Nov 2003 19:06:34 +0000 (UTC)
Hi Ryan,

This looks like a limitation in the serializer. It serializes a DOM using
recursion, so I'm not surprised this might happen with a document with an
element depth of 10,000. I believe there's an option (at least with some
versions of Java) for adjusting the stack size used by the runtime. It
would probably one of the -X options. You might be able to workaround the
problem if you can increase the limit.
On Thu, 6 Nov 2003, Michael Ryan Bannon wrote: > Hello, > > Forgive me if this has been mentioned before in another thread... > > I am running into a StackOverflowError when attempting to serialize a large XML document (10000+ nodes, with a height of 10000). > I have the following method: > > private static String serialize(Document doc) { > > ***************************************** > try { > // Set the output format. > OutputFormat format = new OutputFormat(); > format.setIndent(5); > > // Serialize the document. > Serializer serializer = new XMLSerializer(format); > ByteArrayOutputStream outStream = new ByteArrayOutputStream(); > serializer.setOutputByteStream(outStream); > DOMSerializer domSerializer = serializer.asDOMSerializer(); > domSerializer.serialize(doc); > return outStream.toString(); > > } catch (IOException e) { > System.out.println(e); > } > return null; > } > ***************************************** > > The line "domSerializer.serialize(doc);" is causing a StackOverflowError. > Is there a solution to this? > > Any help is greatly appreciated. > > Thanks, > > Ryan
--------------------------- Michael Glavassevich XML Parser Development IBM Toronto Lab E-mail: E-mail:
Maksym Kovalenko 1068145844Thu, 06 Nov 2003 19:10:44 +0000 (UTC)
Look to me that you run out of memory.
If you really need to serialize all data in the world into memory array, 
use java command line parameter to set maximum heap size (java -Xmx128M).
Michael Ryan Bannon wrote: > Hello, > > Forgive me if this has been mentioned before in another thread... > > I am running into a StackOverflowError when attempting to serialize a > large XML document (10000+ nodes, with a height of 10000). > I have the following method: > > private static String serialize(Document doc) { > > ***************************************** > try { > // Set the output format. > OutputFormat format = new OutputFormat(); > format.setIndent(5); > > // Serialize the document. > Serializer serializer = new XMLSerializer(format); > ByteArrayOutputStream outStream = new ByteArrayOutputStream(); > serializer.setOutputByteStream(outStream); > DOMSerializer domSerializer = serializer.asDOMSerializer(); > domSerializer.serialize(doc); > return outStream.toString(); > > } catch (IOException e) { > System.out.println(e); > } > return null; > } > ***************************************** > > The line "domSerializer.serialize(doc);" is causing a StackOverflowError. > Is there a solution to this? > > Any help is greatly appreciated. > > Thanks, > > Ryan >
Maksym Kovalenko 1068146262Thu, 06 Nov 2003 19:17:42 +0000 (UTC)
stack size, not heap.
Michael was right.
Assuming you're using Sun JVM it'll be java -Xss<size>
Maksym Kovalenko wrote: > Look to me that you run out of memory. > If you really need to serialize all data in the world into memory > array, use java command line parameter to set maximum heap size (java > -Xmx128M). > > Michael Ryan Bannon wrote: > >> Hello, >> >> Forgive me if this has been mentioned before in another thread... >> >> I am running into a StackOverflowError when attempting to serialize a >> large XML document (10000+ nodes, with a height of 10000). >> I have the following method: >> >> private static String serialize(Document doc) { >> >> ***************************************** >> try { >> // Set the output format. >> OutputFormat format = new OutputFormat(); >> format.setIndent(5); >> >> // Serialize the document. >> Serializer serializer = new XMLSerializer(format); >> ByteArrayOutputStream outStream = new ByteArrayOutputStream(); >> serializer.setOutputByteStream(outStream); >> DOMSerializer domSerializer = serializer.asDOMSerializer(); >> domSerializer.serialize(doc); >> return outStream.toString(); >> >> } catch (IOException e) { >> System.out.println(e); >> } >> return null; >> } >> ***************************************** >> >> The line "domSerializer.serialize(doc);" is causing a StackOverflowError. >> Is there a solution to this? >> >> Any help is greatly appreciated. >> >> Thanks, >> >> Ryan >> > > > -- > ------------------------------------------------------------------------ > > Maksym Kovalenko > Software Engineer > Marketswitch Corporation > http://www.marketswitch.com <http://www.marketswitch.com/> > 108 Powers Court, Suite 225 > Dulles, VA 20166 > Phone: +1 (703) 444-6750 ext. 302 > Fax: +1 (703) 444-6812 >
Jacob Kjome 1068160064Thu, 06 Nov 2003 23:07:44 +0000 (UTC)
At 02:16 PM 11/6/2003 -0500, you wrote: >stack size, not heap. >Michael was right. >Assuming you're using Sun JVM it'll be java -Xss<size>
Yes, but make sure <size> is "m", not "M". Jake
>Maksym Kovalenko wrote: >>Look to me that you run out of memory. >>If you really need to serialize all data in the world into memory array, >>use java command line parameter to set maximum heap size (java -Xmx128M). >> >>Michael Ryan Bannon wrote: >>>Hello, >>> >>>Forgive me if this has been mentioned before in another thread... >>> >>>I am running into a StackOverflowError when attempting to serialize a >>>large XML document (10000+ nodes, with a height of 10000). >>>I have the following method: >>> >>> private static String serialize(Document doc) { >>> >>>***************************************** >>> try { >>> // Set the output format. >>> OutputFormat format = new OutputFormat(); >>> format.setIndent(5); >>> >>> // Serialize the document. >>> Serializer serializer = new XMLSerializer(format); >>> ByteArrayOutputStream outStream = new ByteArrayOutputStream(); >>> serializer.setOutputByteStream(outStream); >>> DOMSerializer domSerializer = serializer.asDOMSerializer(); >>> domSerializer.serialize(doc); >>> return outStream.toString(); >>> >>> } catch (IOException e) { >>> System.out.println(e); >>> } >>> return null; >>> } >>>***************************************** >>> >>>The line "domSerializer.serialize(doc);" is causing a StackOverflowError. >>>Is there a solution to this? >>> >>>Any help is greatly appreciated. >>> >>>Thanks, >>> >>>Ryan >>> >> >>-- >> >>---------- >>Maksym Kovalenko >>Software Engineer >>Marketswitch Corporation >><http://www.marketswitch.com/>http://www.marketswitch.com >>108 Powers Court, Suite 225 >>Dulles, VA 20166 >>Phone: +1 (703) 444-6750 ext. 302 >>Fax: +1 (703) 444-6812 > >-- > >---------- >Maksym Kovalenko >Software Engineer >Marketswitch Corporation ><http://www.marketswitch.com/>http://www.marketswitch.com >108 Powers Court, Suite 225 >Dulles, VA 20166 >Phone: +1 (703) 444-6750 ext. 302 >Fax: +1 (703) 444-6812
Home | About | Privacy