Counting amount of memory allocated?

Chris Lattner sabre@nondot.org
Mon Nov 4 15:32:00 GMT 2002


> >How do I go about disabling pool allocation that is happening for these
> >containers?  Ideally I would like to be able to disable it globally with a
> >single #define (such as -D__USE_MALLOC), so that I can just enable it for
> >debug builds.  Do I really have to recompile libstdc++ to do this, or is
> >there an easier way?

> RTFM

And a beautiful manual it is... :)

> GLIBCPP_FORCE_NEW
> http://gcc.gnu.org/onlinedocs/libstdc++/ext/howto.html#3

That's great, but it doesn't work.  I imagine that the whole "Starting
with gcc 3.3" is the part that is biting me, but just in case, I tried it
out (and it produces the same output as before):

csh$ setenv GLIBCPP_FORCE_NEW 1; ./a.out
Start: 36
One map: 251108
empty map: 251108
second map: 251108
map destroyed: 251108

Is there a 3.2 compatible solution to this problem?  Is __USE_MALLOC still
available?  I am running in a single threaded context, so at least those
headaches shouldn't be a problem.

>From what I can gather from this page (GCC 3.1 docs I assume):
http://www.doubleand.tv/doc/cpp-3.1/libstdc++/html/ext/howto.html#3
__USE_MALLOC "should" work, in fact it does appear to with GCC 2.96
(which I know is bad news from all over, you don't have to remind me):

$ ./a.out
Start: 36
One map: 320068
empty map: 68
second map: 320068
map destroyed: 36

So what do I have to do to get one or the other of these working with 3.2?

> Also, you can explicitly force "C" library bits to be de-allocated with

Thanks, luckily I don't have to worry about that.  :)

> I've been thinking of writing up a C++ debugging HOWTO.

You should, it is currently a bit of a black art.  :)

Thanks for all the help, I appologize for being a pest.

-Chris

-- 
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/



More information about the Libstdc++ mailing list