Question

I have a rather memory hungry java application. On my 32 bit systems with Windows XP Professional the application will just run fine if I give it -Xmx1280m. Everything below will end up in an java.lang.OutOfMemoryError: Java heap space exception.

If I run the same application on a 64 bit Windows XP Professional (everything else exactly the same) it requires -Xms1400m to prevent the OutOfMemory condition.

To my understanding, if I have a C program and I compile it for 32 bit and for 64 bit the 64 bit version will need more memory because pointers are wider and so on. In my java example however the virtual machine (Sun) is the same and the bytecode is the same.

Why does it need more memory on the 64 bit machine?

Was it helpful?

Solution

Probably because the virtual machine implementation differs between 32/64 bit architecture in such a way that it consumes more memory (wider types, different GC).

The bytecode is irrelevant when it passes on the tasks to the underlying system. Im not sure that Java and memory-efficient are two terms I would put together anyway :P

OTHER TIPS

Even though your bytecode is the same, the JVM converts that to machine code, so it has all the same reasons as C to require a larger memory footprint.

It's the same reason you already listed for the C program. The 64 bit system uses large memory addresses, causing it to be "leakier" (I believe that's the term I've heard used to describe it).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top