开发者

Netbeans OutOfMemoryError: Java heap space, code formatting

When I format code in netbeans, I recently started getting an "OutOfMemoryError: Java heap space" error.

I've been using netbeans for well over 2 years and this just started happening on the typical machine I develop on. Currently using version 6.9, on an XP machine, 4Gb memory. I have adjusted -J-Xmx to 1024m and even tried 2048m, and it still get errors.

This is a small php script, less than 100 lines. I have had no problem in the past formatting 10,000+ lines without editing -J-Xmx or anything else. 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. 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.reforma开发者_高级运维t(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

Installed 7.0b and reinstalled JRE 6... which is now working fine. Using 7 as 6.9 is unusable when using code formatting. 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. It turned out that the problem was to do with SVN, and was cured by clearing out an SVN cache directory. Read through the bug's "comments" for the details.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜