One thing I don't understand about this code is the line.
       int sz = (int)((memUsed + junk.length/2)/junk.length);

Why is it not just memUsed/junk.length?

Also is it likely a jvm bug that we end up with 9 or are we making wrong assumptions about what the jvm will return for totalMemory() and freeMemory()?

I'm guessing this is trying to round up.

It looks like this code expects that:
 - on a 32 bit machine, memUsed will be appx 40,000, junk.length will be 10,000
   and we will compute sz = 4
 - on a 64 bit machine, memUsed will be appx 80,000, junk.length will be 10,000
    and we will compute sz = 8

Does it sometimes return 4, and sometimes return 9, all on the same machine?

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.

thanks,

bryan

Reply via email to