7

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.

trincot
  • 317,000
  • 35
  • 244
  • 286
Justin
  • 447
  • 4
  • 10
  • 33

4 Answers4

6

In the run configuration screen, go to Arguments tab, add -Xmx8g to the VM arguments text box.

Pradeep Pati
  • 5,779
  • 3
  • 29
  • 43
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

Justin
  • 447
  • 4
  • 10
  • 33
  • I have the same problem; but I still get this problem and the error is this: `Invalid maximum heap size: -Xmx4096M` `The specified size exceeds the maximum representable size.` – Reihan_amn Jan 10 '17 at 03:41
1

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();
Daniel Williams
  • 8,673
  • 4
  • 36
  • 47
  • Yup, it's 64 bit. How do I add -Xmx for other programs than eclipse? – Justin Apr 03 '13 at 22:43
  • It is a command line option. So add it to the `java` command line. If you are launching the programs from Eclipse, you can set the JVM command options from the launcher config; e.g. via the "Run > Run Configurations" Wizard. – Stephen C Apr 03 '13 at 22:50
0

Try adding -d64 option to theeclipse.ini

Sergei Krivonos
  • 4,217
  • 3
  • 39
  • 54