简体   繁体   中英

Heap Space Issue outside Netbeans IDE

EDIT: I ended up doing a combo of both suggested answers, and thus answered my own question, it is the accepted one below, hopefully this helps others in the future!

I'm running 32 bit Java 1.8.0_40 on Windows 7.

I have created a program in Netbeans 8.0 and adjusted the VM Options to be -Xms512m -Xmx2048m.

The program runs quite well inside the Netbeans IDE environment, however upon trying to run the program outside of Netbeans I encounter a heap space out of memory error.

EDIT: I am launching the program via the .jar file that Netbeans creates for the project upon compilation.

I have gone to the Java control panel and applied the same "-Xms512m -Xmx2048m" information to the Runtime Parameters. I am still encountering the heap space out of memory error.

Any suggestions? Where can I go from here? Have I missed a step in making sure there is enough memory in the Runtime Environment outside of Netbeans?

The VM options you use in netbeans can also be used on the command line ie

java -Xms512m -Xmx2048m  -jar yourprg.jar

There are more JVM options available.

Since you are building an independent JAR file, it looks like there is not a clean way to include such options inside your JAR (some people have asked about it here and here without a definitive answer). When in your case, my solution is usually to give away a little shell script with the proper -Xms and -Xmx arguments, along with my JAR file.

I did a combination of the two answers. It ended up being that I had to use a fully qualified name enclosed in quotations to execute the command and since others will be using this program I was able to create a .bat file to do so. The final .bat file ended up looking like this:

java -Xms512m -Xmx2048m -jar "T:\Netbeans Projects\DataLoader\dist\DataLoader.jar"

Thank you to both Jorge_B and Sanj for your help! Hopefully this will help other in the future!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM