This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 195646 - Compiler freezes, needs too much memory
Summary: Compiler freezes, needs too much memory
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Compiler (show other bugs)
Version: 7.0
Hardware: PC Windows 7
: P2 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-18 08:57 UTC by jirka_x1
Modified: 2011-07-08 19:43 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
ant log showing an exception (3.62 KB, application/octet-stream)
2011-02-18 08:57 UTC, jirka_x1
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jirka_x1 2011-02-18 08:57:01 UTC
Created attachment 106141 [details]
ant log showing an exception

Adding a simple function (see below) to a class causes the compiler (and the project scanner) to run forever and eventually to run out of memory (using about 400MB). Without that function the compiler needs one or two seconds to compile the same file.

The offending function is:
    public Form<?> getForm(MLayer aLayer) {
        return (aLayer == null) ? mWForm : getMForm(aLayer);
    }

At least when the ant build target is invoked from the command line, the compiler fails much faster. Before that it reports:

[nb-javac] Note: Attempting to workaround 6512707

See the attachment for the full listing.

The java bug 6512707 is listed as fixed, so maybe the workaround should be removed? Or at least, could the compilation/scanning in the IDE fail similarly fast as when run from command line, instead of freezing the whole IDE?

It is a simple NB Platform project. I can provide the whole project if necessary. The same problem happends in NB 6.9.1.
Comment 1 Jan Lahoda 2011-02-18 09:15:57 UTC
The whole project or some standalone test case would be welcome, as that would make reproducing the bug simpler.

Regarding the workaround for 6512707: the code (annotation processor) detects if the workaround is needed, so the fix was not available in the compiler that was used by the ant build.
Comment 2 Jan Lahoda 2011-02-28 13:56:12 UTC
Seems that the problem is that computing Types.lub() can cause computation of other Types.lub(), leading to repeated computations of Types.lub for the same values. I have tried to workaround that by introducing a cache:
http://hg.netbeans.org/main/nb-javac/rev/5bd693a7052b
This will of course help only for parsing for the editor, the ant-based build uses the javac instance from the JDK. Relates to JDK bug #7015715.
Comment 3 Quality Engineering 2011-03-01 17:55:06 UTC
Integrated into 'main-golden', will be available in build *201103011142* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/19fae2675ce7
User: Jan Lahoda <jlahoda@netbeans.org>
Log: #195646, #196090: updating nb-javac library
Comment 4 jirka_x1 2011-07-08 19:43:29 UTC
Thanks for the fix (unfortunately, as Jan says, the fix does not cover the compilation itself. The JDK bug is verified but closed. Weird).

Just in case somebody has a similar problem, the workaround in my case was to change the ternary operator to the corresponding if statement. Funny, but it works now.