简体   繁体   English

Netbeans IDE之外的堆空间问题

[英]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. 我在Windows 7上运行32位Java 1.8.0_40。

I have created a program in Netbeans 8.0 and adjusted the VM Options to be -Xms512m -Xmx2048m. 我在Netbeans 8.0中创建了一个程序,并将VM选项调整为-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. 该程序在Netbeans IDE环境中运行良好,但是当尝试在Netbeans之外运行程序时,我遇到堆空间内存不足错误。

EDIT: I am launching the program via the .jar file that Netbeans creates for the project upon compilation. 编辑:我通过Netbeans编译时为项目创建的.jar文件启动程序。

I have gone to the Java control panel and applied the same "-Xms512m -Xmx2048m" information to the Runtime Parameters. 我已经转到Java控制面板并将相同的“-Xms512m -Xmx2048m”信息应用于运行时参数。 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? 我是否错过了确保Netbeans之外的运行时环境中有足够内存的步骤?

The VM options you use in netbeans can also be used on the command line ie 您在netbeans中使用的VM选项也可以在命令行上使用,即

java -Xms512m -Xmx2048m  -jar yourprg.jar

There are more JVM options available. 有更多JVM选项可用。

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). 由于您正在构建一个独立的JAR文件,看起来没有一种干净的方法可以在JAR中包含这些选项(有些人在这里这里都没有明确的答案)。 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. 在您的情况下,我的解决方案通常是提供一个带有正确的-Xms和-Xmx参数的小shell脚本以及我的JAR文件。

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. 它最终是我必须使用引号括起来的完全限定名来执行命令,因为其他人将使用这个程序,我能够创建一个.bat文件来执行此操作。 The final .bat file ended up looking like this: 最终的.bat文件最终看起来像这样:

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

Thank you to both Jorge_B and Sanj for your help! 感谢Jorge_B和Sanj的帮助! Hopefully this will help other in the future! 希望这将有助于其他未来!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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