I was reading in netbeans 6, you don't have to set the maximum heap size, it will just look at your computer for that information.
My system has 8 gigs of ram, but my application only has 64mb to play with and it is running out of memory.
I did a:
System.out.println(Runtime.getRuntime().maxMemory());
And it is 66 650 112 bytes (63.5625 megabytes).
my netbeans.config:
-J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-XX:MaxPermSize=200m
I tried to change these numbers, but then netbeans failed to load (JVM error).
How can I increase the maximum size to 1 GB?
EDIT: responding to the comment
If your application has a specific need for heap space, you can set the virtual machine parameters that you would like it to use. For example, I have a default maximum heap size that I use in the default run configuration. I also have larger maximums for run configurations where I know that I will be processing more data.
You can access the run configurations several ways:
It is important to note that setting the maximum heap size does not immediately allocate that much memory. With my current work, I prefer to allow the heap to grow up to the maximum if necessary but also, to be a good neighbor with other services on the machine, I allow it to keep a small heap if things fit. You can, however, specify that heap size should start at the maximum possible size by using the -Xms option.
For example, if you set the virtual machine options to "-Xms1024m -Xmx1024m", the application will grab the entire gig of memory on startup and hold it for the entire run.
End EDIT
If you'd like to ensure that Netbeans always has enough heap space, you can do this one of two easy ways. One is to modify the netbeans.conf file. In mine, the original line reads like so:
netbeans_default_options="-J-client -J-Xverify:none -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-XX:MaxPermSize=200m -J-Dapple.laf.useScreenMenuBar=true -J-Dsun.java2d.noddraw=true"
If you would like to give Netbeans up to one gig of RAM to play with, you can change the line to read like so:
netbeans_default_options="-J-client -J-Xverify:none -J-Xmx1024m -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-XX:MaxPermSize=200m -J-Dapple.laf.useScreenMenuBar=true -J-Dsun.java2d.noddraw=true"
where the "-J-Xmx1024m" argument will allow the heap to grow up to a size of 1024 meg.
However, it's even easier to set the max heap for Netbeans at runtime from a launcher or shortcut. On my machine, I have a launcher that passes the max heap in directly without changing the configuration file:
/usr/local/netbeans-6.8/bin/netbeans -J-Xmx1024m
Feel free to use whichever is most convenient for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With