db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Richard Emberson <rember...@edgedynamics.com>
Subject ClassSize: 32 or 64 bit machine code
Date Wed, 17 May 2006 15:05:21 GMT

In the ClassSize.java file there is the following code:

         // Figure out whether this is a 32 or 64 bit machine.
         Runtime runtime = Runtime.getRuntime();
         long memBase = runtime.totalMemory() - runtime.freeMemory();
         Object[] junk = new Object[10000];
         long memUsed = runtime.totalMemory() - runtime.freeMemory() - 
memBase;
         int sz = (int)((memUsed + junk.length/2)/junk.length);
         int refSize = ( 4 > sz) ? 4 : sz;
System.out.println("refSize = "+refSize);

(minus the print statement). If you paste that code into an
Ant task, a HelloWorld.java main or beanshell, on my 64 bit
linux box one gets:

with the 32 bit 1.4.2_11 jvm: refSize = 9
with the 64 bit 1.5.0_06 jvm: refSize = 4

On a 32 bit linux box with 32 bit jvm: refSize = 9.

How is this used to determine 32 vs 64 bit machine?
Thanks.

RME

-- 
This email message is for the sole use of the intended recipient(s) and
may contain confidential information.  Any unauthorized review, use,
disclosure or distribution is prohibited.  If you are not the intended
recipient, please contact the sender by reply email and destroy all
copies of the original message.

Mime
View raw message