Issue 31409 - Large memory leak in rsc2
Summary: Large memory leak in rsc2
Status: CLOSED FIXED
Alias: None
Product: gsl
Classification: Code
Component: code (show other issues)
Version: 680m44
Hardware: PC Linux, all
: P3 Trivial (vote)
Target Milestone: OOo 2.0
Assignee: philipp.lohmann
QA Contact: issues@gsl
URL:
Keywords:
: 22638 (view as issue list)
Depends on:
Blocks:
 
Reported: 2004-07-13 11:38 UTC by chris
Modified: 2004-09-10 12:24 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
diff of solution (9.69 KB, patch)
2004-08-20 15:15 UTC, philipp.lohmann
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description chris 2004-07-13 11:38:50 UTC
While building ooo20040704 my machine became very ill and ran out of memory.  I
found that rsc2 had already used 2Gb of memory and was still hungry.. :-/

It seems that it leaks large amounts of memory, and this becomes critical when
building many languages at once.  The killer was when trying to build sd/util
with all languages.

I ran valgrind to find out where this memory is being allocated, and that it is
definately a leek:

==13197== 71712512 bytes in 280127 blocks are definitely lost in loss record 41
of 41
==13197==    at 0x3C02140D: malloc (vg_replace_malloc.c:105)
==13197==    by 0x80634FC: RscMem::Malloc(unsigned short) (in
/oo/680/java/openoffice.org680-0.m44+cvs040708/solver/680/unxlngi4.pro/bin/rsc2)
==13197==    by 0x807C46B: MallocString() (in
/oo/680/java/openoffice.org680-0.m44+cvs040708/solver/680/unxlngi4.pro/bin/rsc2)
==13197==    by 0x807C6F0: MakeToken(YYSTYPE*) (in
/oo/680/java/openoffice.org680-0.m44+cvs040708/solver/680/unxlngi4.pro/bin/rsc2)
==13197==    by 0x807CB69: yylex() (in
/oo/680/java/openoffice.org680-0.m44+cvs040708/solver/680/unxlngi4.pro/bin/rsc2)
==13197==    by 0x8077C8B: yyparse() (in
/oo/680/java/openoffice.org680-0.m44+cvs040708/solver/680/unxlngi4.pro/bin/rsc2)
==13197==    by 0x807CF7A: parser(RscFileInst*) (in
/oo/680/java/openoffice.org680-0.m44+cvs040708/solver/680/unxlngi4.pro/bin/rsc2)
==13197==    by 0x80AEE69: RscCompiler::ParseOneFile(unsigned long,
RscCmdLine::OutputFile const*, WriteRcContext const*) (in
/oo/680/java/openoffice.org680-0.m44+cvs040708/solver/680/unxlngi4.pro/bin/rsc2)
==13197==    by 0x80B03FB: RscCompiler::Link() (in
/oo/680/java/openoffice.org680-0.m44+cvs040708/solver/680/unxlngi4.pro/bin/rsc2)
==13197==    by 0x80ADEE2: RscCompiler::Start() (in
/oo/680/java/openoffice.org680-0.m44+cvs040708/solver/680/unxlngi4.pro/bin/rsc2)

[P2 because it breaks builds that build many languages at once]
Comment 1 christof.pintaske 2004-07-14 11:17:51 UTC
the memory leak may not be fixable without rewriting the whole parser, since we
don't know when yylex() is ready with the string. 

As a workaround compile fewer languages at a time, or recompile rsc2 while
setting MINBUF in rsclex.hxx to something smaller than the current 256 (try 32). 

We will see if can do more. 

malloc                         /usr/lib/valgrind/vgskin_memcheck.so
RscMem::Malloc(unsigned short) rsc/source/tools/rsctools.cxx:361
MallocString()                 rsc/source/parser/rsclex.cxx:153
MakeToken(YYSTYPE*)            rsc/source/parser/rsclex.cxx:275
yylex()                        rsc/source/parser/rsclex.cxx:433
yyparse()                      bison.simple:432
parser(RscFileInst*)           rsc/source/parser/rsclex.cxx:533
RscCompiler::ParseOneFile(unsigned long, RscCmdLine::OutputFile const*,
WriteRcContext const*)                                rsc/source/rsc/rsc.cxx:837
RscCompiler::Link()            rsc/source/rsc/rsc.cxx:1072
RscCompiler::Start()           rsc/source/rsc/rsc.cxx:588
main                           rsc/source/prj/gui.cxx:151
Comment 2 christof.pintaske 2004-07-14 12:07:24 UTC
cp->pl: as discussed, probably duplicate. Please have a look
Comment 3 philipp.lohmann 2004-07-14 12:19:15 UTC
*** Issue 22638 has been marked as a duplicate of this issue. ***
Comment 4 philipp.lohmann 2004-07-14 12:19:35 UTC
set target
Comment 5 hjs 2004-07-15 10:56:56 UTC
.
Comment 6 philipp.lohmann 2004-07-15 18:22:50 UTC
In CWS vcl25 i checked in a version that does not waste the memory anymore;
however since CWS bmpres01 the .srs files are parsed anew for every language rc
file written. I hope that we can find a way to avoid that, too.
Comment 7 philipp.lohmann 2004-07-16 13:12:19 UTC
pl->ka: you said you would look into the multiple parse issue if time allowed;
therefore i'll send this issue to you. If time doesn't permit the change please
simply forward it to hjs for verification as the most critical issue is fixed.
Comment 8 ooo 2004-07-20 11:12:20 UTC
accepted
Comment 9 philipp.lohmann 2004-08-02 13:41:28 UTC
Assign to me again; we will look into the reparsing matter again later; the
memory leak is fixed for now.
Comment 10 philipp.lohmann 2004-08-02 13:41:58 UTC
fixed in CWS vcl25
Comment 11 philipp.lohmann 2004-08-03 15:50:36 UTC
verified in CWS vcl25
Comment 12 foskey 2004-08-20 14:50:03 UTC
Can you outline what files are fixed so I can cross patch and verify whether my
other problem is related.
Comment 13 philipp.lohmann 2004-08-20 15:15:59 UTC
Created attachment 17256 [details]
diff of solution
Comment 14 philipp.lohmann 2004-08-20 15:16:38 UTC
attached diff (against m49) of changed files
Comment 15 philipp.lohmann 2004-09-10 12:24:26 UTC
merged in 680m54