Difference between 32 bit and 64-bit java installation

In computing, a byte is the unit of data and processing of data is generally denoted as bit processing. In general, there exist two types of processors namely a 32-bit processor and a 64-bit processor. In 64-bit processors will have more storage and memory hence it results in high performance.

Java also has the support of 32-bit as well as 64-bit but it is highly recommended to use 64-bit process to have good performance of the system. Similarly, on 32-bit machine, the limit is 4 GB, and about only 1.5 GB is actually available for user applications.

Strictly speaking, on a 32-bit CPU architecture machine, you should install 32-bit java/JRE. On the other hand, on a 64-bit CPU architecture machine, you are free to choose between 32-bit java/JRE and 64-bit java/JRE. Both will work just fine. In fact, on 64-bit machine decision of JRE version depends on other factors such as maximum memory needed to run your application on high load scenarios.

Please note that high availability of memory doesn’t come for free. It does have a cost on runtime e.g.

1) 30-50% of more heap is required on 64-bit in comparison to 32-bit. Why? Mainly because of the memory layout in 64-bit architecture. First of all – object headers are 12 bytes on 64-bit JVM. Secondly, object references can be either 4 bytes or 8 bytes, depending on JVM flags and the size of the heap. This definitely adds some overhead compared to the 8 bytes on headers on 32-bit and 4 bytes on references.

2) Longer garbage collection pauses. Building up more heap means there is more work to be done by GC while cleaning it up from unused objects. What it means in real life is that you have to be extra cautious when building heaps larger than 12-16GB. Without fine tuning and measuring you can easily introduce full GC pauses spanning several minutes which can result in showstoppers.

a .class file generated using a 32-bit java compiler be used on 64-bit java as well.The reason for that Java byte code is independent from 32-bit or 64-bit systems. That’s why it is said that the compiled java code shall be executable on “any” system. Remember that just the virtual machine is compiled for a special system architecture because of some native files it has in packaged bundle, and native files are never platform independent.

If so, then how 32-bit applications run on 64-bit systems? Answer is that 64-bit systems include a compatibility layer called WoW64, which actually switches the processor back and forth between 32-bit and 64-bit modes depending on which thread needs to execute; making 32-bit software run smoothly even in the 64-bit environment.

Here are few important points

  1. The garbage collector will take more time to do the cleanup, so full garbage collection will have a longer pause time.

  2. Client JVM is only available for 32-bit JVM and not for 64-bit

  3. Java features support might differ these 2 types

So, from these two points, you can conclude that an application running on 64 bit JVM will consume more space in comparison when the same application runs on the 32-bit version.

Happy Learning !!