[jdom-interest] About JDOM performance

phil at triloggroup.com phil at triloggroup.com
Tue May 22 16:24:46 PDT 2001

Hi Jason, happy to read you again.

I think that single linked list is definitively a bad idea since it requires lots of work for simply inserting/removing
a new element, comparing to the gain of 4 bytes per item (38 instead of 42).
Another solution is to add the prev/next data member, which prevents from allocating an entry object ecah time. But this
practice is discouraged because it ties an object to a list and does not allow an object to be in several lists. And you
need a wrapper to the String objects, when added to the element content.

For my point of view, I can't see any pb by replacing the LinkedList with an ArrayList. The only changes will perhap's
concern some LinkedList's specific methods, like addFirst()...


                    Jason Hunter                                                                                   
                    <jhunter at coll        To:     phil at triloggroup.com                                              
                    ab.net>              cc:     jdom-interest at jdom.org                                            
                                         Subject:     Re: [jdom-interest] About JDOM performance                   

phil at triloggroup.com wrote:
> In fact, the memory overhead for an object is something like 30
> bytes, depending on the JVM.
> The size for a 100,000 items in a linked is approximatly
> 100000*(30+4*3)=4,200,000 bytes, regarding less the entry
> itself. On the over hand, the array list, in the worst case, is
> 150,000*4=600,000 bytes => 7 times lower !! The only
> drawback is that memory must be contiguous. But this is not a
> constrainy under Win32 since the memory is logically
> contiguous but allocated in blocks.
> Also note that creating plenty of LinkedList.Entry objects
> stress the garbage collector.
> I will definitively remove the LinkedLists from my own JDOM
> sources and replace them by ArrayLists.

Phil, seems you have a compelling argument for why we should use
ArrayList always.  Anyone have a counter?

Jools, does this have a profound effect on your next-gen list work?
Might make it easier on you since you wouldn't have to manage a
singly-linked list.  Perhaps you could just wrap/extend an ArrayList.


More information about the jdom-interest mailing list