« Return to Thread: How to find document size

RE: How to find document size

by Michael Kay :: Rate this Message:

Reply to Author | View in Thread

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.
 
Michael Kay
 
 


From: jdom-interest-bounces@... [mailto:jdom-interest-bounces@...] On Behalf Of Jasmin_Mehta@...
Sent: 18 January 2008 19:05
To: Tatu Saloranta
Cc: jdom interest
Subject: Re: [jdom-interest] How to find document size


how can I find amount of memory Java uses for JDOM tree?

and how can I serialize it?



Tatu Saloranta <cowtowncoder@...>
Sent by: jdom-interest-bounces@...

01/18/2008 12:51 PM

To
jdom interest <jdom-interest@...>
cc
Subject
Re: [jdom-interest] How to find document size






--- Jasmin_Mehta@... wrote:

> I need to know the xml document size as it is when
> it comes out from
> Oracle's 'XMLTYPE' datatype. I am appending
> resultset records one after
> another in one xml document until it reaches certain
> size. For this
> purpose I need to know the size of

There is no efficient way to get exact size; either
for serialized or amount of memory Java uses for the
JDOM tree. To know exact size, you have to serialize
it: and even when using dummy OutputStream there's
linear cost for doing that, and with incremental
calls, it has N^2 complexity (essentially dog slow for
sizable docs).

But you can approximate size yourself; this would give
rough idea of either serialized size or amount of
memory used to store the JDOM tree in memory (latter
which is usually 3x - 4x of the former, depending on
kind of document).

The main question is what is this to be used for?
To avoid getting a DB exception from Oracle (there's a
max size for column), to avoid Denial-of-service
attack (memory used on server side for processing doc)
or something else?
As long as approximate size is enough (size that's
within, say, 2x of the actual size) it should be
doable quite efficiently.

-+ Tatu +-



     ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page.
http://www.yahoo.com/r/hs
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@...

******************************************************************************
ATTENTION ATTENTION ATTENTION ATTENTION ATTENTION
Our domain name is changing. Please take note of the sender's
e-Mail address and make changes to your personal address list,
if needed. Both domains will continue to work, only for a limited
time.
******************************************************************************
This email and any files transmitted with it are intended solely for
the use of the individual or agency to whom they are addressed.
If you have received this email in error please notify the Navy
Exchange Service Command e-mail administrator. This footnote
also confirms that this email message has been scanned for the
presence of computer viruses.

Thank You!
******************************************************************************


_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@...

 « Return to Thread: How to find document size

LightInTheBox - Buy quality products at wholesale price!