Re: Bignums, object grind, and garbage collection
Lew wrote:
John Ersatznom wrote:
I'm currently leaning toward rolling my own wrapper classes, but using
the JScience LargeInteger under the hood with a PoolContext.
Is a PoolContext an object pool for the LargeInteger objects? If so, it
might have poorer performance than small immutable objects, since
long-lived objects are subject to more expensive GC than short-lived ones.
This assumes that a) LargeIntegers are, despite their name, small :) and
b) the PoolContext objects get gc'd so much more expensively it
outweighs their getting gc'd much less frequently. (One LargeInteger
that gets 10 uses gets 1 more expensive gc per 10 uses instead of 10
less expensive gcs per 10 uses. So it has to be at least Nx more
expensive for one that lives N times as long as usual.
Only test runs of your classes with immutable vs. pooled objects will
tell us for sure. With different GC strategies. I wonder if anyone has
run comparable tests before.
I'm going to, before too too much longer, although there's a somewhat
confounded benchmark at http://jscience.org/doc/benchmark.html --
confounded because it doesn't separate the effects of PoolContexting
from the effects of using LargeInteger in place of BigInteger. Separate
comparisons of LargeInteger (PoolContext) to LargeInteger (no context)
and LargeInteger (no context) to BigInteger would be more informative.