Ludwig Weinzierl
Ludwig Weinzierl

Reputation: 16614

Does a 32bit process need more memory when it runs on a 64bit system?

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?

Upvotes: 3

Views: 477

Answers (3)

Gandalf
Gandalf

Reputation: 9855

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).

Upvotes: 3

Aiden Bell
Aiden Bell

Reputation: 28384

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

Upvotes: 5

Yishai
Yishai

Reputation: 91931

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.

Upvotes: 4

Related Questions