Bryan Pendleton wrote:
Does it sometimes return 4, and sometimes return 9, all on the same
machine?
Yes sometimes 4, 5,9 and as high as 12 on the same linux 32bit box. If
I just run this code standalone, (outside of Derby) I consistently get
5. One thing I wonder about is if there might be other threads
allocating objects at the time this is running, which would throw
things off. Maybe this class should get loaded at boot time, so we can
be sure nothing else is going on.
Also I think I might try to gc() before the measurements and see if
that makes a difference, but it seems to me that would only make the
value larger.
Army mentioned to me that we might be able to use Map.Entry for this
calculation more effectively, so I am looking at that too, but don't
quite understand how that would work.
I don't think this is likely to be a JVM bug. I think it's more likely
that this code just isn't very robust.