Java Reference
In-Depth Information
32-BIT OR 64-BIT?
If you have a 32-bit operating system, then you must use a 32-bit version of the JVM. If you have
a 64-bit operating system, then you can choose to use either the 32- or 64-bit version of Java.
Don't assume that just because you have a 64-bit operating system, you must also use a 64-bit
version of Java.
If the size of your heap will be less than about 3 GB, the 32-bit version of Java will be faster and
have a smaller footprint. This is because the memory references within the JVM will be only 32
bits, and manipulating those memory references is less expensive than manipulating 64-bit refer-
ences (even if you have a 64-bit CPU). The 32-bit references also use less memory.
Chapter 8 discusses compressed ordinary object pointers (oops), which is a way that the JVM can
use 32-bit addresses even within the 64-bit JVM. However, even with that optimization, the 64-bit
JVM will have a larger footprint because the native code it uses will still have 64-bit addresses.
The downside to the 32-bit JVM is that the total process size must be less than 4 GB (3 GB on
some versions of Windows, and 3.5 GB on some old versions of Linux). That includes the heap,
permgen, and the native code and native memory the JVM uses. Programs that make extensive
use of long or double variables will be slower on a 32-bit JVM because they cannot use the
CPU's 64-bit registers, though that is a very exceptional case.
Programs that fit within a 32-bit address space will run anywhere between 5% and 20% faster in a
32-bit JVM than a similarly configured 64-bit JVM. The stock batching program discussed earlier
in this chapter, for example, is 20% faster when run on a 32-bit JVM on my desktop.
When downloading Java for a given operating system, there are only two options: a 32-bit or
a 64-bit binary. So clearly, the 32-bit binary can be expected to have (up to) two compilers,
while the 64-bit binary will have only a single compiler. (In fact, the 64-bit binary will have
two compilers, since the client compiler is needed to support tiered compilation. But a 64-bit
JVM cannot be run with only the client compiler.)
Once installed, though, things become a little more complicated. On most platforms, the
32-bit and 64-bit binaries install separately. You can have both binaries installed on your
computer, but you must refer to them via separate paths. Hence, on the machine I use for
Linux testing, I have binaries installed in /export/VMs/jdk1.7.0-32bit and /export/VMs/
jdk1.7.0-64bit , and I choose between them by setting my PATH accordingly.
On Solaris, things are different: the 64-bit installation overlays the 32-bit installation. Hence
all three compilers are available from the same path. This makes it much easier for the end
user; among other things, it means that if Java is installed system-wide in /usr/bin , a user can
Search WWH ::

Custom Search