Re: How to find document size
| Newsgroups | gmane.comp.java.jdom.general |
|---|---|
| Message-ID | <OF6AAE1611.92FFE0C0-ON852573D4.0068C58B-852573D4.0068C9F5@nexweb.us> |
how can I find amount of memory Java uses for JDOM tree? and how can I serialize it? Tatu Saloranta <[email protected]> Sent by: [email protected] 01/18/2008 12:51 PM To jdom interest <[email protected]> cc Subject Re: [jdom-interest] How to find document size --- [email protected] 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/[email protected] ****************************************************************************** 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/[email protected]