64-bit Java will not allocate more than 2 GB of heap memory

I run my program from eclipse and use 64-bit Java, but I still can not allocate it to accommodate more than 2 GB of memory. I run some tests, so I need a lot of memory.

I have this in my eclipse.ini: -Xmx8g

I want him to use all my memory. Could this be due to the 32-bit version of eclipse? I'm not sure what I have for the eclipse.

I tried sending -Xmx8g to VMArg when the program started. I am running 64bit windows 7 and 64bit JRE.

+6
source share
4 answers

After trying everything else, it seems that VMArguments just don't work in eclipse.

Changing VM's default DEFAULT arguments in eclipse (finally!):

Inserting virtual machine arguments in the JRE: while Eclipse is open, open Preferences (for Windows: located under the Window menu item. For Mac: located under the Eclipse menu item), open the Java section, click "Installed JREs", click the used JRE ( there will probably be jre6), click the "Change ..." button and paste this into the default VM arguments:

-Xms256M -Xmx8192M

+2
source

On the startup configuration screen, go to the "Arguments" tab, add -Xmx8g to the "VM Settings" text box.

+5
source

Try to do this:

 System.getProperty("sun.arch.data.model") 

And see if it will return 32 or 64 inside your program

You also need to add -Xmx to your startup options for your program, not just eclipse.

You can test your program -Xmx is configured correctly by doing:

 Runtime.getRuntime().maxMemory(); 
+1
source

You need to add -d64 to eclipse.ini

0
source

All Articles