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 222460 - Too much memory used to parse some files
Summary: Too much memory used to parse some files
Status: RESOLVED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: Code Model (show other bugs)
Version: 7.3
Hardware: All All
: P2 normal (vote)
Assignee: Vladimir Voskresensky
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-20 12:41 UTC by Egor Ushakov
Modified: 2014-04-24 02:07 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
proposed fix (4.09 KB, text/plain)
2012-11-22 10:38 UTC, Egor Ushakov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Egor Ushakov 2012-11-20 12:41:43 UTC
There are files with such extensive macro usage (in Boost for example) that parsing these files consume too much memory.
It happens because we tokenize, expand and keep the full file instead of a small portion that we need at the moment.
Comment 1 Egor Ushakov 2012-11-20 12:42:25 UTC
The fix is to get back optimization we threw away long ago.
Comment 2 Egor Ushakov 2012-11-20 12:58:22 UTC
fixed in:
http://hg.netbeans.org/cnd-main/rev/559d4c029670
Comment 3 Quality Engineering 2012-11-21 13:44:54 UTC
Integrated into 'main-golden', will be available in build *201211211016* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/559d4c029670
User: Egor Ushakov <gorrus@netbeans.org>
Log: fixed #222460 - Too much memory used to parse some files
Comment 4 Egor Ushakov 2012-11-22 10:36:29 UTC
the fix does not work with the current infrastructure that keeps all tokens in AST
Comment 5 Egor Ushakov 2012-11-22 10:38:06 UTC
Created attachment 128251 [details]
proposed fix
Comment 6 Quality Engineering 2012-11-30 02:45:55 UTC
Integrated into 'main-golden', will be available in build *201211300001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/ee02326e791b
User: Egor Ushakov <gorrus@netbeans.org>
Log: reverted fix for #222460 - Too much memory used to parse some files:
it does not help existing infrastructure
Comment 7 Alexander Simon 2014-02-18 08:37:24 UTC
It is a stopper for a studio target.
Biggest objects on OOM:
+-----------------------------------------------------------------------------------+---------------------+------------------------+------------------------+
|                                                          Class Name               |       Objects       |      Shallow Size      |     Retained Size      |
+-----------------------------------------------------------------------------------+---------------------+------------------------+------------------------+
|  +---java.lang.Object[]                                                           |      72,105    0 %  |    189,871,776    5 %  |  3,850,116,392   91 %  |
|  |                                                                                |                     |                        |                        |
|  +---java.lang.Thread                                                             |          14    0 %  |          2,240    0 %  |  3,846,986,848   91 %  |
|  |                                                                                |                     |                        |                        |
|  +---org.netbeans.modules.cnd.modelimpl.parser.ParserProviderImpl$Antlr2CppParser |           1    0 %  |            128    0 %  |  3,826,562,744   91 %  |
|  |                                                                                |                     |                        |                        |
|  +---org.netbeans.modules.cnd.modelimpl.parser.CPPParserEx                        |           1    0 %  |            232    0 %  |  3,826,562,576   91 %  |
|  |                                                                                |                     |                        |                        |
|  +---org.netbeans.modules.cnd.antlr.TokenBuffer                                   |           1    0 %  |             48    0 %  |  3,826,561,784   91 %  |
|  |                                                                                |                     |                        |                        |
|  +---java.util.ArrayList                                                          |      56,016    0 %  |      2,240,640    0 %  |  3,774,507,624   90 %  |
|  |                                                                                |                     |                        |                        |
|  +---org.netbeans.modules.cnd.apt.impl.support.MacroExpandedToken                 |  30,637,800   37 %  |  1,470,614,400   35 %  |  3,567,130,160   85 %  |
|  |                                                                                |                     |                        |                        |
|  +---org.netbeans.modules.cnd.apt.impl.support.APTMacroParamExpansion             |  43,540,324   53 %  |  2,089,935,552   50 %  |  2,658,139,080   63 %  |
|  |                                                                                |                     |                        |                        |
+-----------------------------------------------------------------------------------+---------------------+------------------------+------------------------+
Comment 8 Vladimir Voskresensky 2014-02-18 14:32:56 UTC
limit number of generated tokens for one macro expanded stream as 8M:

http://hg.netbeans.org/cnd-main/rev/8968ad1ff1fd
http://hg.netbeans.org/cnd-main/rev/1d2257bfe461
Comment 9 Quality Engineering 2014-02-19 02:46:05 UTC
Integrated into 'main-silver', will be available in build *201402190001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/8968ad1ff1fd
User: Vladimir Voskresensky <vv159170@netbeans.org>
Log: fixed #222460 - Too much memory used to parse some files
- limit generated tokens as 8 millions
Comment 10 Vladimir Voskresensky 2014-02-19 11:24:19 UTC
extra fix under flag to check memory optimization
http://hg.netbeans.org/cnd-main/rev/b55755974792
Comment 11 Vladimir Voskresensky 2014-02-19 16:49:19 UTC
better place for tokens limitation:
http://hg.netbeans.org/cnd-main/rev/0a93d7aafaaa
Comment 12 Quality Engineering 2014-02-20 03:03:55 UTC
Integrated into 'main-silver', will be available in build *201402200001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/b55755974792
User: Vladimir Voskresensky <vv159170@netbeans.org>
Log: extra fix #222460: Too much memory used to parse some files
Comment 13 Quality Engineering 2014-04-24 02:07:41 UTC
Integrated into 'releases/release80', will be available in build *201404240045* or newer. Wait for official and publicly available build.

Changeset: http://hg.netbeans.org/releases/rev/afd87eaacf38
User: Vladimir Voskresensky <vv159170@netbeans.org>
Log: extra fix #222460: Too much memory used to parse some files
- move logic into APTMacroExpandedStream
(transplanted from 0a93d7aafaaaf91a42aa33c1587b4f8d743fcf56)