Re: Short-lived Objects - good or bad?
Andreas Leitgeb wrote:
Lew <lew@lewscanon.com> wrote:
Read the section "The Myth of Expensive Object Allocation" in
<http://java.sun.com/developer/technicalArticles/Interviews/goetz_qa.html>
Thanks for this pointer - this is something I can mention for
my defense :-)
PS: if the java-version in use is still 1.4 (this is not
my choice, of course): does this make a difference, or was
1.4's GC already comparable to current's ?
The Sun Java site has information on changes between version, but I am fairly
sure that Sun improved its GC engines (there are more than one, you know) with
every Java version. Of course, if your JVM didn't come from Sun then you have
to check elsewhere for that information.
There are a variety of -XX parameters to 'java' regarding GC.
More important than GC are the facts that Java 1.4 is obsolescent, to be
retired in just a few months, and that there were important changes to
interthread-communication semantics (the "memory model") between creaky old
1.4 and sleek, new Java 5. Whoops - Java 5 enters End-of-Life itself this year!
Back to your question - Sun introduced its generational collector by 1.4, so
you can rely on the points Mr. Goetz made. With Java 1.4 allocation was
already much, much cheaper than the myths purport, and de-allocation
essentially free in the 92-98% case. Your defense will rest on sound
principles even with that arch?ologically interesting version.
--
Lew