[jdom-interest] Memory problem

Dr. Olaf Diehl o.diehl at proplant.de
Mon Oct 21 08:50:20 PDT 2002


Hello,

this is not about XML but about memory measurement.

I've written a method debugSize which calculates the size of an object
network via reflection. The attached java source file has a main with sample
code and javadoc.
The method is not fast, measuring 1MB may take a minute if there are lots of
tiny objects. Be careful with listeners, the code will follow these
references. You can switch the flag debugSizeTransient to decide if the code
should follow transient fields (but e.g. HashMap entry array is transient,
too!).

Perhaps it can help you to locate memory problems with JDOM.

Regards

    Olaf

*****************************************************
* Olaf Diehl
* pro_Plant Gesellschaft für Agrar- und Umweltinformatik mbH
* http://www.proPlant.de
* Nevinghoff 40
* D-48147 Münster
*
* EMail: O.Diehl at proPlant.de
* Tel.:  +49 251 987 97 59
* Fax.:  +49 251 987 97 99
*****************************************************

----- Original Message -----
From: Elliotte Rusty Harold <elharo at metalab.unc.edu>
To: Marcus Andersson <marcus.andersson at active-tv.com>;
<jdom-interest at jdom.org>
Sent: Thursday, October 17, 2002 6:51 PM
Subject: Re: [jdom-interest] Memory problem


> At 6:34 PM +0200 10/17/02, Marcus Andersson wrote:
> Hello everyone,
>
> I have a problem regarding memory when using JDOM. Before I say
> anything else I just want to say I have seen that there are some
> issues in the archive regarding my problem.
>
> Anyway, the problem is that a 1Mb big XML file becomes about 140Mb in
> memory when I have used SAXBuilder to build the JDOM document. I have
> seen in previous mails that there may be a factor 10 when building to
> a JDOM document. Now it is a factor 140. That cannot be correct. I
> must have done something wrong. It did cause me OutOfMemoryError in
> the beginning but I found -Xmx128m flag in some previous mail on this
> topic.
>
>
> How do you measure the memory used by the document?
> --
>
> +-----------------------+------------------------+-------------------+
> | Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
> +-----------------------+------------------------+-------------------+
> |          XML in a  Nutshell, 2nd Edition (O'Reilly, 2002)          |
> |              http://www.cafeconleche.org/books/xian2/              |
> |  http://www.amazon.com/exec/obidos/ISBN%3D0596002920/cafeaulaitA/  |
> +----------------------------------+---------------------------------+
> |  Read Cafe au Lait for Java News:  http://www.cafeaulait.org/      |
> |  Read Cafe con Leche for XML News: http://www.cafeconleche.org/    |
> +----------------------------------+---------------------------------+
> _______________________________________________
> To control your jdom-interest membership:
>
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MemoryTools.java
Type: application/octet-stream
Size: 24240 bytes
Desc: not available
Url : http://jdom.org/pipermail/jdom-interest/attachments/20021021/9971211e/MemoryTools.obj


More information about the jdom-interest mailing list