我在 Windows 7 64 位中使用 32 位版本的 Java。该系统具有 6 GB 的 RAM。但是当操作系统为 JVM 分配内存时,它不会超过 1.5 GB(与 32 位操作系统相同)。可能的原因是什么,JVM 不允许有足够的内存。如果可能的话如何解决它?我无法升级到 64 位 JVM。
4 回答
Windows 上的 32 位进程仍然受到与在 32 位 Windows 操作系统上运行相同的限制。请参阅此问题的答案。
Oracle 的该指南建议 32 位 JVM 可以使用大约 1.5GB。
32 位 JVM 的最大理论堆限制为 4G。由于各种额外的限制,例如可用交换、内核地址空间使用、内存碎片和 VM 开销,实际上限制可以低得多。在大多数现代 32 位 Windows 系统上,最大堆大小范围为 1.4G 到 1.6G。
为了能够使用更多内存,您必须升级到 64 位。不幸的是,64 位 JVM 无法加载 32 位 dll,因此对 dll 的调用必须从不同的进程进行,并且您必须使用 rpc 机制与进程对话,而不是直接使用 dll。很多。的工作,但它可以完成。
32 bit application will not be able to use more that 4GB of RAM. In practice, it will not be able to use more than 3GB because it needs some virtual memory space reserved for operating system.
Besides that, by default JVM allocates up to a quarter of available RAM. If you want to override this use option:
java -XX:DefaultMaxRAMFraction=1
It should use all available RAM that is feasible for 32 bit application.