[jdom-interest] Re: New realease, Text class... Arghh
Dennis Sosnoski
dms at sosnoski.com
Thu Jan 10 10:10:08 PST 2002
Short-lived object creation/recycling is one thing Sun has optimized
heavily in Hot Spot. I've always felt that creating lots of short-lived
object was just a sign of poorly designed code, and would rather they'd
concentrated on other areas. They didn't ask me, though... ;-)
The issue in iterator vs indexing a linked list is that the iterator
overhead is constant, while the indexing cost is proportional to the
length of the list, O(n). If you're going through the entire list in
sequence, this becomes O(n^2). If you know your lists are never going to
have more than a few items this is fine; otherwise, you're better off
using an Iterator.
Avoiding object creation completely is going to give the best
performance, which is why I like having calls to access attributes and
content directly.
- Dennis
Alex Rosen wrote:
>>especially since object creation overhead
>>is pretty low for Hot Spot JVMs.
>>
>
>Really? I was under the impression that object creation (plus the extra GC
>work that it will cause later on) is one of the slowest things a VM can do,
>even for HotSpot. I could imagine that it might be slower than accessing a
>linked list using an index, but I didn't think that it was "pretty low"
>overhead, I thought it was just the opposite.
>
>Alex
>
More information about the jdom-interest
mailing list