public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/48481] New: C++ overloading memory hog
@ 2011-04-06 15:32 jakub at gcc dot gnu.org
  2011-04-06 15:48 ` [Bug c++/48481] " jakub at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-04-06 15:32 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48481

           Summary: C++ overloading memory hog
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Keywords: memory-hog
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jakub@gcc.gnu.org
                CC: jason@gcc.gnu.org


#define A(n) \
struct S##n { int i; }; \
S##n v##n;\
extern int foo (S##n, S##n);\
extern void bar (S##n);
#define B(n) A(n##0) A(n##1) A(n##2) A(n##3) A(n##4) A(n##5) A(n##6) A(n##7)
A(n##8) A(n##9)
#define C(n) B(n##0) B(n##1) B(n##2) B(n##3) B(n##4) B(n##5) B(n##6) B(n##7)
B(n##8) B(n##9)
#define D(n) C(n##0) C(n##1) C(n##2) C(n##3) C(n##4) C(n##5) C(n##6) C(n##7)
C(n##8) C(n##9)
#ifndef N
#define N 10000
#endif
#if N == 1000
#define E(n) D(n##0)
#elif N == 2000
#define E(n) D(n##0) D(n##1)
#elif N == 3000
#define E(n) D(n##0) D(n##1) D(n##2)
#else
#define E(n) D(n##0) D(n##1) D(n##2) D(n##3) D(n##4) D(n##5) D(n##6) D(n##7)
D(n##8) D(n##9)
#endif
E(0)

void
foo ()
{
#undef A
#define A(n) if (foo (v##n, v##n)) bar (v##n);
  E(0)
}

testcase eats huge amounts of memory.  With -DN=1000 -O0 it compiles quickly,
using 432768 kB of memory (852MB in top), with -DN=2000 -O0 it already uses
1672544 kB (3.5GB in top).  With -DN=3000 it took around 8GB in top.

In --enable-gather-detailed-mem-stats -fmem-report, for N=1000 I see:
cp/tree.c:1447 (ovl_cons)                          64032000:15.1%          0:
0.0%     256032: 1.8%          0: 0.0%    2009001
c-family/c-common.c:9556 (make_tree_vector)       159840120:37.8%          0:
0.0%          0: 0.0%          0: 0.0%    3996003
cp/search.c:1135 (build_baselink)                 191952000:45.4%          0:
0.0%          0: 0.0%          0: 0.0%    3999000
Total                                             422660566          8986384   
     14294815          2724053         10281399
source location                                     Garbage            Freed   
         Leak         Overhead            Times
and for N=2000:
cp/tree.c:1447 (ovl_cons)                         256064000:15.3%          0:
0.0%     512032: 1.9%          0: 0.0%    8018001
c-family/c-common.c:9556 (make_tree_vector)       639680120:38.1%          0:
0.0%          0: 0.0%          0: 0.0%   15992003
cp/search.c:1135 (build_baselink)                 767904000:45.8%          0:
0.0%          0: 0.0%          0: 0.0%   15998000
Total                                            1677099246         12464328   
     27061439          3876781         40545425
source location                                     Garbage            Freed   
         Leak         Overhead            Times


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2011-06-30 21:10 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-06 15:32 [Bug c++/48481] New: C++ overloading memory hog jakub at gcc dot gnu.org
2011-04-06 15:48 ` [Bug c++/48481] " jakub at gcc dot gnu.org
2011-04-07  2:03 ` jason at gcc dot gnu.org
2011-04-07 12:16 ` jakub at gcc dot gnu.org
2011-04-07 20:47 ` jason at gcc dot gnu.org
2011-04-08  6:08 ` jason at gcc dot gnu.org
2011-04-08  6:08 ` jason at gcc dot gnu.org
2011-04-08  6:08 ` jason at gcc dot gnu.org
2011-04-08 15:17 ` jason at gcc dot gnu.org
2011-04-28 17:00 ` rguenth at gcc dot gnu.org
2011-04-28 17:07 ` jason at gcc dot gnu.org
2011-06-30 21:10 ` jason at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).