32位进程在64位系统上运行时是否需要更多内存?

时间:2022-09-01 11:00:09

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.

我有一个相当内存饥饿的java应用程序。在我使用Windows XP Professional的32位系统上,如果我给它-Xmx1280m,应用程序将运行正常。以下所有内容最终都会出现在java.lang.OutOfMemoryError:Java堆空间异常中。

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.

如果我在64位Windows XP Professional上运行相同的应用程序(其他一切完全相同),它需要-Xms1400m来防止OutOfMemory条件。

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.

根据我的理解,如果我有一个C程序并且我将其编译为32位而对于64位64位版本将需要更多内存,因为指针更宽等等。在我的java示例中,虚拟机(Sun)是相同的,字节码是相同的。

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

为什么64位机器需要更多内存?

3 个解决方案

#1


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

可能是因为虚拟机实现在32/64位架构之间存在差异,因此它消耗更多内存(更宽的类型,不同的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

将任务传递给底层系统时,字节码无关紧要。我不确定Java和内存效率是否是我将要组合的两个术语:P

#2


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.

即使您的字节码相同,JVM也会将其转换为机器代码,因此它与C的原因完全相同,需要更大的内存占用。

#3


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

这与您已经为C程序列出的原因相同。 64位系统使用大内存地址,导致它“漏洞”(我相信这是我用来描述它的术语)。

#1


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

可能是因为虚拟机实现在32/64位架构之间存在差异,因此它消耗更多内存(更宽的类型,不同的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

将任务传递给底层系统时,字节码无关紧要。我不确定Java和内存效率是否是我将要组合的两个术语:P

#2


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.

即使您的字节码相同,JVM也会将其转换为机器代码,因此它与C的原因完全相同,需要更大的内存占用。

#3


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

这与您已经为C程序列出的原因相同。 64位系统使用大内存地址,导致它“漏洞”(我相信这是我用来描述它的术语)。