[jdom-interest] Getting rid of text caching

Jason Hunter jhunter at collab.net
Thu Aug 17 19:49:36 PDT 2000


I've been thinking this afternoon about the text caching we do for
getText() and getTextTrim().  I'm wondering if it gives us enough bang
for our buck.  The advantage is speeding up accesses to the text data
after the first request; the cost is increased memory consumption (all
text content duplicated 2 or 3 times in memory!) and more complicated
code -- and perhaps a synchronization call.  

On the topic of the sync call, remember what Joe Bowbeer brought up,
that because of Java's strange behavior for us to be really safe in
multithreaded read-only mode, we'd have to synchronize our caching
logic?  That's something that we'd have to pay for on every request. 
It's not a high price on modern JVMs perhaps, but it's probably in the
neighborhood of just calculating the text value again, and I'd like to
see JDOM perform well on all JVMs.

I don't have time to run OptimizeIt to have real numbers backing up my
thoughts, maybe someone else does, but in general I can't think of a
compelling reason to keep the caching logic.

-jh-



More information about the jdom-interest mailing list