问题
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.
I have this in my 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.
I've tried sending in -Xmx8g to VMArgs when running the program. I'm running 64-bit windows 7 and a 64-bit JRE.
回答1:
In the run configuration screen, go to Arguments tab, add -Xmx8g
to the VM arguments text box.
回答2:
After trying everything else, it looked like VMArguments were simply not working in eclipse.
Changing the DEFAULT VM args within eclipse worked (finally!):
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:
-Xms256M -Xmx8192M
回答3:
Try doing this:
System.getProperty("sun.arch.data.model")
And see if it returns 32 or 64 inside your program
Also you need to add -Xmx to your launch params for your program not just for eclipse.
You can verify your program's -Xmx is configured properly by doing:
Runtime.getRuntime().maxMemory();
回答4:
You only need to add -d64
to your eclipse.ini
来源:https://stackoverflow.com/questions/15799476/64-bit-java-wont-allocate-more-than-2gb-of-heap-memory