java NetBeans 内存不足错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27636272/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
NetBeans Low on Memory Error
提问by Java Nerd
I am new to this kind of error in Netbeans. I have been working in Java J2SE using my net beans 8.0.2. I am doing Fuzzy Search on Strings usually strings having 300-500 length. I am using Levenshtein and Jaro Winkler Algorithms to find the Distance between the strings. There are about 1500 iterations to find the distance between the strings! The problem is that my net beans often gives error for:
我对 Netbeans 中的这种错误很陌生。我一直在使用我的 net bean 8.0.2 在 Java J2SE 中工作。我正在对字符串进行模糊搜索,通常字符串的长度为 300-500。我正在使用 Levenshtein 和 Jaro Winkler 算法来查找字符串之间的距离。大约需要 1500 次迭代才能找到字符串之间的距离!问题是我的网豆经常出现以下错误:
Low on Memory, Error Unable to Compile
I have done some search online to get rid of this error and found how to increase the heap size by adding
我在网上做了一些搜索来摆脱这个错误,并找到了如何通过添加来增加堆大小
-Xms3G
command means to give 3GB space for the heap! but the error still comes up in the compilation process and project run in net beans.
命令意味着为堆提供 3GB 空间!但是在编译过程和在net bean中运行的项目中仍然出现错误。
Can somebody help me out how to get rid of this error because when it happen i got this error
有人可以帮我解决这个错误,因为当它发生时我得到了这个错误
java.lang.noClassDefError
Please help me getting rid of this error I am a newbie for this error!
请帮我摆脱这个错误我是这个错误的新手!
采纳答案by Java Nerd
The simplest answer for my problem was a trick to identify. I had a number of netbeans projects into my working directory. Suppose that my directory D:\NetBeans\WorkSpace contains about 300 projects! What I done is that simplify the directory moved the old projects into a new directory and only a few projects left into my netbeans working space. The error message goes off after moving a number of projects into a new directory. The thing is when netbeans starts up it loads the projects into the memory and if you have a lot of projects into the loading directory it will cause to leak the memory!
我的问题最简单的答案是识别技巧。我的工作目录中有许多 netbeans 项目。假设我的目录 D:\NetBeans\WorkSpace 包含大约 300 个项目!我所做的是简化目录将旧项目移动到新目录中,并且只有少数项目留在我的 netbeans 工作空间中。将多个项目移动到新目录后,错误消息消失。问题是当 netbeans 启动时,它会将项目加载到内存中,如果加载目录中有很多项目,则会导致内存泄漏!
回答by pmverma
With -Xms3G
, it means that your JVM will be started with Xms
amount of memory, the initial memory allocation.
使用-Xms3G
,这意味着您的 JVM 将启动Xms
内存量,即初始内存分配。
But instead use -Xmx3G
which will be able to use a maximum of Xmx
amount of memory, the maximum memory allocation.
而是使用 -Xmx3G
which 将能够使用最大Xmx
的内存量,最大的内存分配。
1.Netbeans Heap Size
1.Netbeans 堆大小
If you want to increase the NetbeansIDE heap size, then edit the following file.(the etc folder from your Netbeans installation dir)
如果要增加 NetbeansIDE 堆大小,请编辑以下文件。(Netbeans 安装目录中的 etc 文件夹)
C:\Program Files\NetBeans\etc\netbeans.conf
Find the following line and add -J-Xmx3G
, you can specify any size. I have provided 3G for eg.
找到以下行并添加-J-Xmx3G
,您可以指定任何大小。我已经提供了例如 3G。
netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-Xmx3G -J-XX:PermSize=32m ......."
2. Project settings for running a project by increasing Heap size from Netbeans
2. 通过增加来自 Netbeans 的 Heap 大小来运行项目的项目设置
Right Click Project -> Properties -> Run -> VM Options -> Customize Button.
You will find many options for VM, specify value for Xmx
.
右键单击项目 -> 属性 -> 运行 -> VM 选项 -> 自定义按钮。您会发现 VM 的许多选项,请指定Xmx
.
3. Run a jar file by providing VM options to increase heap size, outside of Netbeans.
3. 通过提供 VM 选项来运行 jar 文件以增加 Netbeans 之外的堆大小。
Run form command line or write a script.
运行表单命令行或编写脚本。
java -Xmx3G -jar filename.jar
Hope this may help.
希望这可能会有所帮助。