Reputation: 103677
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?
Upvotes: 4
Views: 26314
Reputation: 880
The easy way. Go to
/usr/share/applications
Check if netbeans file exist there, " if there is no netbeans file - select any other file(ex: termianl)" and copy netbeans file(if not terminal file) to desktop. {Don't move - if any error you can change later.}
Open this file(netbeans or terminal) in text editor(gedit). Replace its content to.
[Desktop Entry]
Encoding=UTF-8
Name=NetBeans IDE 7.4
Comment=The Smarter Way to Code
Exec=/opt/netbeans-7.4/bin/netbeans -J-Xmx1024m
Icon=/opt/netbeans-7.4/nb/netbeans.png
Categories=Application;Development;Java;IDE
Version=1.0
Type=Application
Terminal=0
GenericName[en_IN]=Custom NB Launcher
Check Exec : is it point to correct netbeans location, also Icon : to set the icon.
IMPORTANT :
Don't forget to modify Exec : -J-Xmx1024m
In this change 1024 according to your ram size.
Upvotes: 0
Reputation: 22312
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.
Upvotes: 14
Reputation: 2936
This command line give to your Java program a 64Mb initial and 256Mb maximum heap size.
java -Xms64m -Xmx256m jdbc_prog
Good luck!
Upvotes: 7