简体   繁体   English

Netbeans OutOfMemoryError:Java堆空间,代码格式

[英]Netbeans OutOfMemoryError: Java heap space, code formatting

When I format code in netbeans, I recently started getting an "OutOfMemoryError: Java heap space" error. 当我在netbeans中格式化代码时,我最近开始收到“OutOfMemoryError:Java堆空间”错误。

I've been using netbeans for well over 2 years and this just started happening on the typical machine I develop on. 我已经使用netbeans超过2年了,这刚开始发生在我开发的典型机器上。 Currently using version 6.9, on an XP machine, 4Gb memory. 目前在XP机器上使用版本6.9,4Gb内存。 I have adjusted -J-Xmx to 1024m and even tried 2048m, and it still get errors. 我已经将-J-Xmx调整为1024m甚至尝试了2048m,但它仍然会出错。

This is a small php script, less than 100 lines. 这是一个小的PHP脚本,不到100行。 I have had no problem in the past formatting 10,000+ lines without editing -J-Xmx or anything else. 我没有问题,在过去格式化10,000多行而不编辑-J-Xmx或其他任何东西。 I am not running any code or debugging or unit testing or anything, just the built-in Source -> Format. 我没有运行任何代码或调试或单元测试或任何东西,只是内置的源 - >格式。

I've tried removing code to see if there was a specific section that is causing problems. 我已经尝试删除代码以查看是否存在导致问题的特定部分。 From what I can gather, if I add a single control structure, no matter what it contains, I get a memory error. 从我可以收集到的,如果我添加一个控件结构,无论它包含什么,我都会收到内存错误。

Even: 甚至:

if($i == 1) {}

causes the memory error. 导致内存错误。 If I check memory usage, Netbeans has no problem using up all of the memory it can. 如果我检查内存使用情况,Netbeans可以用尽所有内存。 Any help on this would be appreciated. 任何有关这方面的帮助将不胜感激。

Here's the stack trace generated when I get the error: 这是我收到错误时生成的堆栈跟踪:

java.lang.OutOfMemoryError: Java heap space
    at org.netbeans.modules.php.editor.indent.FormatVisitor.addFormatToken(FormatVisitor.java:1002)
    at org.netbeans.modules.php.editor.indent.FormatVisitor.visit(FormatVisitor.java:859)
    at org.netbeans.modules.php.editor.parser.astnodes.Program.accept(Program.java:92)
    at org.netbeans.modules.php.editor.indent.TokenFormatter$1.run(TokenFormatter.java:354)
    at org.netbeans.editor.GuardedDocument.runAtomic(GuardedDocument.java:314)
    at org.netbeans.modules.php.editor.indent.TokenFormatter.reformat(TokenFormatter.java:344)
    at org.netbeans.modules.php.editor.indent.PHPFormatter.reformat(PHPFormatter.java:129)
    at org.netbeans.modules.csl.core.GsfReformatTask$1.run(GsfReformatTask.java:105)
    at org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(ParserManager.java:154)
    at org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(ParserManager.java:138)
    at org.netbeans.modules.parsing.impl.TaskProcessor$1.call(TaskProcessor.java:200)
    at org.netbeans.modules.parsing.impl.TaskProcessor$1.call(TaskProcessor.java:197)
    at org.netbeans.modules.masterfs.filebasedfs.utils.FileChangedManager.priorityIO(FileChangedManager.java:160)
    at org.netbeans.modules.masterfs.providers.ProvidedExtensions.priorityIO(ProvidedExtensions.java:227)
    at org.netbeans.modules.parsing.impl.Utilities.runPriorityIO(Utilities.java:66)
    at org.netbeans.modules.parsing.impl.TaskProcessor.runUserTask(TaskProcessor.java:197)
    at org.netbeans.modules.parsing.api.ParserManager.parse(ParserManager.java:106)
    at org.netbeans.modules.csl.core.GsfReformatTask.reformat(GsfReformatTask.java:95)
    at org.netbeans.modules.editor.indent.TaskHandler$MimeItem.runTask(TaskHandler.java:550)
    at org.netbeans.modules.editor.indent.TaskHandler.runTasks(TaskHandler.java:317)
    at org.netbeans.modules.editor.indent.IndentImpl.reformat(IndentImpl.java:320)
    at org.netbeans.modules.editor.indent.FormatterImpl.reformat(FormatterImpl.java:190)
    at org.netbeans.editor.ActionFactory$FormatAction$1$1.run(ActionFactory.java:1683)
    at org.netbeans.editor.GuardedDocument.runAtomicAsUser(GuardedDocument.java:344)
    at org.netbeans.editor.ActionFactory$FormatAction$1.run(ActionFactory.java:1651)
    at org.netbeans.modules.progress.ui.RunOffEDTImpl$1.run(RunOffEDTImpl.java:160)
    at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1418)
    at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:1957)

Looks like there are a ton of similar reports to this issue: http://statistics.netbeans.org/analytics/exception.do?id=472651 看起来这个问题有很多类似的报道: http//statistics.netbeans.org/analytics/exception.do?id = 472651

Installed 7.0b and reinstalled JRE 6... which is now working fine. 安装7.0b并重新安装JRE 6 ......现在工作正常。 Using 7 as 6.9 is unusable when using code formatting. 使用7作为6.9在使用代码格式时不可用。 Would still like to figure out how to fix this issue though. 仍然想知道如何解决这个问题。

I found this NetBeans bug which reports a problem which sounds similar to yours. 我发现这个NetBeans错误报告了一个与你的问题类似的问题。 It turned out that the problem was to do with SVN, and was cured by clearing out an SVN cache directory. 事实证明问题与SVN有关,并通过清除SVN缓存目录来解决。 Read through the bug's "comments" for the details. 阅读bug的“评论”了解详细信息。

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

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