Search code examples
java32bit-64bitbytecode

How do I make 32 bit or 64 bit application?


While making programs, how do I make sure that a particular application is a 64 bit application or a 32 bit application.

Is it possible to hard-code that the app would be 64 bit or 32 bit respectively and if possible would it be necessary for the 64 bit app to take more memory than usual 32 bit app?

I am aware about the memory limitation with 32 bit applications/hardware.


Solution

  • There is one byte code regardless of whether it will be used for 32-bit or 64-bit.

    This means you can use libraries which were compiled on 32-bit machines before there was any 64-bit JVM, on a 64-bit JVM.

    64-bit JVMs can use more memory, but not as much as you might think as modern 64-bit JVM use Compressed Oops so that you can use 32-bit references for up to 32 GB of heap. (you can use more off heap memory as well)

    Many 32-bit JVM on 32-bit OSes are limited to 1.2 to 1.5 GB of memory. On 64-bit OS this limit might be 2.5 to 3.5 GB depending on the OS. A 64-bit JVM on a 64-bit OS is practically limited to around 1 TB of memory but this limit could be lifted in future (and depends on the OS)

    The only difference you can have is if you use a JNI. A JNI shared library is dependant either a 32-bit or 64-bit library and you might only have one (in which case you ca only load it on a JVM of the same bit-ness) or it might behave differently.