Re: JDOM and memory
Noel Grandin <[email protected]>
| Newsgroups | gmane.comp.java.jdom.general |
|---|---|
| Message-ID | <[email protected]> |
Sounds reasonable to me.
I've always been aware that at a certain document size, I had to switch from using JDOM to parsing things at the SAX layer.
This means I can delay some of decisions a little longer :-)
Rolf wrote:
> Hi all.
>
> Memory optimization has never been a top priority for JDOM. At the same time, for what it does, JDOM is not a
> 'terrible' memory user. Still, I have done some analysis, and, I believe I can trim about a quarter to a half of 'JDOM
> Overhead' memory usage by making two 'simple' changes....
>
> The first is to merge the ContentList class in to the Element class (and also in to Document). This will reduce the
> number of Java objects by about half, and that will save about 32 bytes per Element at a minimum in a 64-bit JRE.
> Additionally, by lazy-initialization of the Content array, we can save memory on otherwise 'empty' Elements.
>
> This can be done by extending the Element (and perhaps Document) class to extend 'List'. It can all be done in a
> 'backward compatible' way, but also leads to some interesting possibilities, like:
>
> for (Content c : element) {
> ... do something
> }
>
> (for backward compatibility, Element.getContent() will return 'this').
>
>
> The second change is to make the AttributeList instance in Element a lazy-initialization. This would save memory on
> all Elements that have no attributes, but would have an impact for people who sub-class the Element class and may
> expect the attributes field to be non-null.
>
>
> I am trying to get a feel for how important this sort of optimization may be. If there is interest then I will make
> some changes, and test the impact. I may make a separate branch in github to test it out....
>
> If the above changes are unrealistic then I don't think it makes sense to even try....
>
> Rolf
> _______________________________________________
> To control your jdom-interest membership:
> http://www.jdom.org/mailman/options/jdom-interest/[email protected]
>
Disclaimer: http://www.peralex.com/disclaimer.html
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/[email protected]