Domanda

I have a java program that I developed using Netbeans 7.0.1 to parse and save large CSV files. Because of the size of the CSV files I needed to increase the heap size of the JVM. In 7.0.1 I set the heap size to use 4GB of my 8GB on my system using the -Xmx4096m specification under Project ->Properties -> VM Options in Netbeans. It worked fine in 7.0.1.

Now I'm trying to run it in Netbeans 7.1 and I'm getting the following for output from Netbeans

Could not create the Java virtual machine.
Invalid maximum heap size: -Xmx4096m
The specified size exceeds the maximum representable size.
Java Result: 1

I've changed nothing from default in Netbeans when I get this error.

I figured that maybe in 7.1 they had "locked" the heap size in the netbeans.config file so I went there.

First I tried this:

netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-Xmx4906m -J-XX:PermSize=32m -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.zip.disableMemoryMapping=true"

That gives me a Failed to create JVM popup at Netbeans splash screen.

Then I tried this:

netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-XX:MaxPermSize=4096m -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.zip.disableMemoryMapping=true"

Netbeans seems to like that better as the load bar will go all the way to "Done loading modules." but then it just hangs on the splash screen. I let it hang there for 5 mins before killing it.

This isn't a show stopper for me since I can still run it fine under 7.0.1 but was wondering if anyone had a solution to this. Seems like it should be an easy fix but I'm just overlooking something?

Thanks for your time.

È stato utile?

Soluzione

It looks like you installed your NetBeans with a 32-bit java.exe, Edit your netbeans.conf in C:\Program Files (x86)\NetBeans 7.1\etc\ or C:\Program Files\NetBeans 7.1\etc\ and make sure it says (replace jdk1.7.0_03 with the version you actually intend on using):

...
# Default location of JDK, can be overridden by using --jdkhome <dir>:
netbeans_jdkhome="C:\Program Files\Java\jdk1.7.0_03"
...

and not

...
# Default location of JDK, can be overridden by using --jdkhome <dir>:
netbeans_jdkhome="C:\Program Files (x86)\Java\jdk1.7.0_03"
...

note that the "(x86)" in Windows means 32-bit, or just edit your project and pick a 64-bit JVM. You may have to add your 64-bit JVM to Tools->Java Platforms. Of course if you aren't using Windows the specifics will be different but it will still be a 32-bit vs 64-bit issue.

This situation usually arises when someone wants to use a newer JVM but they accidently install the 32-bit version instead of the 64-bit. Also note: you can configure your project to run/debug in a 64-bit JVM while NetBeans itself is running in a 32-bit JVM, so you don't actually have to modify netbeans.conf to make your project capable of allocated 4GB.

In summary:

  1. Make sure you have a 64-bit JDK installed
  2. Make sure your 64-bit JDK is listed in your Java Platforms in NetBeans
  3. Make sure Your Project->Properties->Libraries->Java Platform is set to the 64-bit JDK you want to use.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top