Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JRE 32bit vs 64bit

I've been using Java for a while now, and my typical ritual of setting up a new dev machine requires the norm of downloading and installing the latest JDK from Oracle's site.

This prompted an unusual question today, does it matter if I use the 32bit or 64bit JRE bundle?

From thinking back on it, I've installed both versions before and my normal toolchain plugs happily in (Eclipse). In my day-to-day programming, I do not recall ever having to change something or think about something in a different way just because I was using the 64bit JRE (or targetting the 64bit JRE for that respect).

From my understanding of 64bit vs. 32bit - it really boils down to how the numbers are stored underneath the covers... and I do know that int is a 32 bits and long is 64 bits... same with float being 32 bits and double is 64 bits -- so is it just that Java has abstracted even this subtlety away, and perhaps has been "64 bit compatible" all along?

I'm sure I'm missing something here besides not being able to install a 64 bit JRE onto a 32 bit system.

like image 433
SnakeDoc Avatar asked Jun 24 '13 22:06

SnakeDoc


People also ask

Is Jre 32 or 64-bit?

The IDL and ENVI Help System, along with the IDL Workbench, require 32-bit JRE's to operate properly. Windows 64-bit systems are able to utilize 32-bit and 64-bit JRE's keeping them in separate locations for system clarity. Installing the 32-bit JRE on a 64-bit Windows system is straight forward.

Is Java 64-bit better?

64-bit perform better if you need much more than 1.2 GB. On some platforms you can get up to 3 GB but if you want 4 - 384 GB for example, 64-bit is your only option.

Should I get Java x86 or x64?

The difference is that Java binaries compiled as x86 (32-bit) or x64 (64-bit) applications respectively. On a 64-bit Windows you can use either version, since x86 will run in WOW64 mode. On a 32-bit Windows you should use only x86 obviously.

When should I use 32bit vs 64bit?

When it comes to computers, the difference between 32-bit and a 64-bit is all about processing power. Computers with 32-bit processors are older, slower, and less secure, while a 64-bit processor is newer, faster, and more secure.


2 Answers

64-bit vs. 32-bit really boils down to the size of object references, not the size of numbers.

In 32-bit mode, references are four bytes, allowing the JVM to uniquely address 2^32 bytes of memory. This is the reason 32-bit JVMs are limited to a maximum heap size of 4GB (in reality, the limit is smaller due to other JVM and OS overhead, and differs depending on the OS).

In 64-bit mode, references are (surprise) eight bytes, allowing the JVM to uniquely address 2^64 bytes of memory, which should be enough for anybody. JVM heap sizes (specified with -Xmx) in 64-bit mode can be huge.

But 64-bit mode comes with a cost: references are double the size, increasing memory consumption. This is why Oracle introduced "Compressed oops". With compressed oops enabled (which I believe is now the default), object references are shrunk to four bytes, with the caveat that the heap is limited to four billion objects (and 32GB Xmx). Compressed oops are not free: there is a small computational cost to achieve this big reduction in memory consumption.

As a personal preference, I always run the 64-bit JVM at home. The CPU is x64 capable, the OS is too, so I like the JVM to run in 64-bit mode as well.

like image 64
cambecc Avatar answered Oct 17 '22 08:10

cambecc


As you note, primitive numeric types in Java are well-defined.

However, the choice between 32-bit and 64-bit JVMs can matter if your Java application is using native-code libraries, which may be built for use in a 32-bit application, a 64-bit application, or both.

If you have native libraries that support only 32-bit applications, you either need to use a 32-bit JVM, or build 64-bit versions of the libraries.

like image 33
Andy Thomas Avatar answered Oct 17 '22 07:10

Andy Thomas