You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Michael Ryan Bannon <mr...@uwaterloo.ca> on 2003/11/09 23:48:01 UTC

Re: Serialization StackOverflowError

Forgive me if people have seen this before, but I tried sending this to the
mailing list twice already and it didn't show up (at least, in my Inbox).



This is what I originally tried to do, but to no avail.
At first, I looked to java.sun.com and saw similar issues with related
solutions; aside from increasing the stack, a solution was to rewrite
readObject/writeObject as the Java string serializer has a poor
performance due to recursion (which brings the stack to max).

(BTW, I made a quick fix by altering my project experiments a bit :)

When serializing a DOM tree, I'm assuming that the serialization algorithm
is using a recursive approach.  Is this correct?

Oh, one other interesting thing I noticed...I stopped getting the overflow
when I switched one of my upper classes to a thread instead of a regular
object.  Does Java have different parameters for stack sizes?  (As I write
this, I'm looking into it...but if somebody already knows, that would be
greatly appreciated.)

 Thanks,

 Ryan

>
> On Thu, 6 Nov 2003, Jacob Kjome wrote:
>
> > 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
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> >
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org