java 如何将 JVM 的内存大小增加到 1GB 以上
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17151919/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to increase memory size for JVM beyond 1gb
提问by user2479100
When I try to set -Xms
and -Xmx
values more than 1gb, I am getting an error:
当我尝试设置-Xms
和-Xmx
值超过1GB,我得到一个错误:
Error occurred during initialization of VM
虚拟机初始化时出错
My pc has 8GB of RAM.
我的电脑有 8GB 的内存。
I need to hold and manipulate a huge amount of data in memory.
我需要在内存中保存和操作大量数据。
回答by selig
A 32-bit JVM can have a maximum heap size of at most 4GB - in some systems it's less due to various technical reasons (such as the need for contiguous memory). Try using a 64-bit version, assuming you're on a 64-bit machine.
32 位 JVM 的最大堆大小最多为 4GB - 在某些系统中,由于各种技术原因(例如需要连续内存),它会更少。假设您使用的是 64 位机器,请尝试使用 64 位版本。
The reason for this is that the maximum number of addresses that you can point to with 32 bits is 2^32, which is 4GB. This theoretical maximum can never really be accessed by the user as it is needed by the JVM for Klass
files (the internal representation of your code) and other stuff.
这样做的原因是您可以用 32 位指向的最大地址数是 2^32,也就是 4GB。这个理论上的最大值永远不会被用户真正访问,因为 JVM 需要它来Klass
存储文件(代码的内部表示)和其他东西。
Also see this question.
另请参阅此问题。
回答by umangm
If you are using 64 bit os than the real solution is adding -d64 to force it to run in 64 bits and therefore allocate the 4GBs.
如果您使用的是 64 位操作系统,那么真正的解决方案是添加 -d64 以强制它以 64 位运行,从而分配 4GB。
回答by M Sach
i would definitely suggest you to go thru article
我肯定会建议您阅读文章
Apart from Ram, xmx paramters also depends on parameters like os,jvm bit etc.
除了 Ram,xmx 参数还取决于 os、jvm bit 等参数。
Also would suggest you to ahve statistics to determine how much free memory is there. See http://viralpatel.net/blogs/getting-jvm-heap-size-used-memory-total-memory-using-java-runtime/to determine how much meory is in use and free memory.
还建议您进行统计以确定有多少可用内存。请参阅http://viralpatel.net/blogs/getting-jvm-heap-size-used-memory-total-memory-using-java-runtime/以确定正在使用的内存量和可用内存量。
To have best utilization it should be both i.e 64 bit os and 64 bit bit vm
为了获得最佳利用,它应该同时是 64 位操作系统和 64 位虚拟机
On 32-bit editions of Windows, applications have 4 gigabyte (GB) of virtual address space available. The virtual address space is divided so that 2-GB is available to the application and the other 2-GB is available only to the system.See http://msdn.microsoft.com/en-us/library/Aa366521
在 32 位版本的 Windows 上,应用程序有 4 GB 的可用虚拟地址空间。虚拟地址空间被划分为 2-GB 可用于应用程序,另外 2-GB 仅可用于系统。请参阅http://msdn.microsoft.com/en-us/library/Aa366521
so make sure you have enough memory(whatever you are mentioning against params xms and xmx) with the program i mentioned above
所以请确保您有足够的内存(无论您针对 params xms 和 xmx 提到什么)我上面提到的程序
回答by Ivan Herlambang
IMHO it's about the same problem with slight difference in question..
恕我直言,这是关于相同的问题,但略有不同。
Eclipse memory allocation problem
As you can see Java Runtime Environment are set in Java Control Panel. Try to add Runtime parameter e.g -Xmx3072m
in Runtime Parameter's column.
如您所见,Java 运行时环境是在 Java 控制面板中设置的。尝试添加运行时参数,例如-Xmx3072m
在运行时参数的列中。
Or perhaps you could check this article out..
或者你可以看看这篇文章。。
How to Increase Java Memory in Windows 7
Hope it's help solving the problem...
希望对解决问题有所帮助...
Regards, Ivan
问候,伊万