<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6000.16587" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=426272319-18012008><FONT face=Arial
color=#0000ff size=2>Tatu asked you a perfectly reasonable question (how
accurate does your information need to be?), and explained why he was asking. So
it seems rather discourteous to come back with more questions rather than
answering him.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=426272319-18012008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=426272319-18012008><FONT face=Arial
color=#0000ff size=2>Michael Kay</FONT></SPAN></DIV>
<DIV><SPAN class=426272319-18012008><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=426272319-18012008><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><BR></DIV>
<BLOCKQUOTE dir=ltr
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> jdom-interest-bounces@jdom.org
[mailto:jdom-interest-bounces@jdom.org] <B>On Behalf Of
</B>Jasmin_Mehta@nexweb.org<BR><B>Sent:</B> 18 January 2008
19:05<BR><B>To:</B> Tatu Saloranta<BR><B>Cc:</B> jdom
interest<BR><B>Subject:</B> Re: [jdom-interest] How to find document
size<BR></FONT><BR></DIV>
<DIV></DIV><BR><FONT face=sans-serif size=2>how can I find amount of memory
Java uses for JDOM tree?</FONT> <BR><BR><FONT face=sans-serif size=2>and how
can I serialize it?</FONT> <BR><BR><BR><BR>
<TABLE width="100%">
<TBODY>
<TR vAlign=top>
<TD width="40%"><FONT face=sans-serif size=1><B>Tatu Saloranta
<cowtowncoder@yahoo.com></B> </FONT><BR><FONT face=sans-serif
size=1>Sent by: jdom-interest-bounces@jdom.org</FONT>
<P><FONT face=sans-serif size=1>01/18/2008 12:51 PM</FONT> </P>
<TD width="59%">
<TABLE width="100%">
<TBODY>
<TR vAlign=top>
<TD>
<DIV align=right><FONT face=sans-serif size=1>To</FONT></DIV>
<TD><FONT face=sans-serif size=1>jdom interest
<jdom-interest@jdom.org></FONT>
<TR vAlign=top>
<TD>
<DIV align=right><FONT face=sans-serif size=1>cc</FONT></DIV>
<TD>
<TR vAlign=top>
<TD>
<DIV align=right><FONT face=sans-serif size=1>Subject</FONT></DIV>
<TD><FONT face=sans-serif size=1>Re: [jdom-interest] How to find
document size</FONT></TR></TBODY></TABLE><BR>
<TABLE>
<TBODY>
<TR vAlign=top>
<TD>
<TD></TR></TBODY></TABLE><BR></TR></TBODY></TABLE><BR><BR><BR><FONT
size=2><TT><BR>--- Jasmin_Mehta@nexweb.org wrote:<BR><BR>> I need to know
the xml document size as it is when<BR>> it comes out from <BR>>
Oracle's 'XMLTYPE' datatype. I am appending<BR>> resultset records one
after <BR>> another in one xml document until it reaches certain<BR>>
size. For this <BR>> purpose I need to know the size of <BR><BR>There is no
efficient way to get exact size; either<BR>for serialized or amount of memory
Java uses for the<BR>JDOM tree. To know exact size, you have to
serialize<BR>it: and even when using dummy OutputStream there's<BR>linear cost
for doing that, and with incremental<BR>calls, it has N^2 complexity
(essentially dog slow for<BR>sizable docs).<BR><BR>But you can approximate
size yourself; this would give<BR>rough idea of either serialized size or
amount of<BR>memory used to store the JDOM tree in memory (latter<BR>which is
usually 3x - 4x of the former, depending on<BR>kind of document).<BR><BR>The
main question is what is this to be used for?<BR>To avoid getting a DB
exception from Oracle (there's a<BR>max size for column), to avoid
Denial-of-service<BR>attack (memory used on server side for processing
doc)<BR>or something else?<BR>As long as approximate size is enough (size
that's<BR>within, say, 2x of the actual size) it should be<BR>doable quite
efficiently.<BR><BR>-+ Tatu +-<BR><BR><BR><BR>
____________________________________________________________________________________<BR>Never
miss a thing. Make Yahoo your home page.
<BR>http://www.yahoo.com/r/hs<BR>_______________________________________________<BR>To
control your jdom-interest
membership:<BR>http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com<BR></TT></FONT><BR>
<P><FONT size=1><FONT
face=arial,helvetica,sans-serif><STRONG>******************************************************************************<BR></STRONG><FONT
color=#ff0000>ATTENTION ATTENTION ATTENTION ATTENTION ATTENTION</FONT> <BR>Our
domain name is changing. Please take note of the sender's<BR>e-Mail address
and make changes to your personal address list,<BR>if needed. Both domains
will continue to work, only for a
limited<BR>time.<BR>******************************************************************************<BR>This
email and any files transmitted with it are intended solely for <BR>the use of
the individual or agency to whom they are addressed. <BR>If you have received
this email in error please notify the Navy <BR>Exchange Service Command e-mail
administrator. This footnote <BR>also confirms that this email message has
been scanned for the<BR>presence of computer viruses.</FONT></FONT></P>
<P><FONT size=1><FONT face=arial,helvetica,sans-serif>Thank You!
<BR><STRONG>******************************************************************************</STRONG></FONT></FONT></P></BLOCKQUOTE></BODY></HTML>