eclipse 64 位 java 不会分配超过 2GB 的堆内存
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15799476/
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
64-bit java won't allocate more than 2GB of heap memory
提问by Justin
I'm running my program from eclipse and using 64-bit java, but I still can't get it to allocate more than 2GB of memory. I'm running some benchmarks so I need a lot of memory.
我正在从 eclipse 运行我的程序并使用 64 位 java,但我仍然无法让它分配超过 2GB 的内存。我正在运行一些基准测试,所以我需要大量内存。
I have this in my eclipse.ini: -Xmx8g
我的 eclipse.ini 中有这个:-Xmx8g
I want it to use all my memory. Could this be due to a 32-bit version of eclipse? I'm not sure what I have for eclipse.
我希望它使用我所有的记忆。这可能是由于 32 位版本的 eclipse 吗?我不确定我对日食有什么。
I've tried sending in -Xmx8g to VMArgs when running the program. I'm running 64-bit windows 7 and a 64-bit JRE.
我试过在运行程序时将 -Xmx8g 发送到 VMArgs。我正在运行 64 位 Windows 7 和 64 位 JRE。
采纳答案by Justin
After trying everything else, it looked like VMArguments were simply not working in eclipse.
在尝试了其他一切之后,看起来 VMArguments 在 eclipse 中根本不起作用。
Changing the DEFAULT VM args within eclipse worked (finally!):
在 eclipse 中更改 DEFAULT VM args 有效(终于!):
Inserting VM arguments into your JRE: while Eclipse is open, open up Preferences (for Windows: located under Window menu item. for Mac: located under Eclipse menu item), open the Java section, click on Installed JREs, click on the JRE being used (probably will be jre6), click on the Edit... button, and insert this into the Default VM Arguments:
将 VM 参数插入您的 JRE:当 Eclipse 打开时,打开 Preferences(对于 Windows:位于 Window 菜单项下。对于 Mac:位于 Eclipse 菜单项下),打开 Java 部分,点击 Installed JREs,点击 JRE使用过(可能是 jre6),单击 Edit... 按钮,并将其插入到 Default VM Arguments 中:
-Xms256M -Xmx8192M
-Xms256M -Xmx8192M
回答by Pradeep Pati
In the run configuration screen, go to Arguments tab, add -Xmx8g
to the VM arguments text box.
在运行配置屏幕中,转到参数选项卡,添加-Xmx8g
到 VM 参数文本框。
回答by Daniel Williams
Try doing this:
尝试这样做:
System.getProperty("sun.arch.data.model")
And see if it returns 32 or 64 inside your program
看看它在你的程序中返回 32 还是 64
Also you need to add -Xmx to your launch params for your program not just for eclipse.
此外,您还需要将 -Xmx 添加到您的程序的启动参数中,而不仅仅是 Eclipse。
You can verify your program's -Xmx is configured properly by doing:
您可以通过执行以下操作来验证您的程序的 -Xmx 是否正确配置:
Runtime.getRuntime().maxMemory();
回答by Sergei
You only need to add -d64
to your eclipse.ini
您只需要添加-d64
到您的eclipse.ini