What is the default allocator with 3.4.3?

Robert Zeh rzeh@efs-us.com
Wed Feb 9 14:49:00 GMT 2005


I am using gcc 3.4.3 on Solaris 2.8, and on Red Hat 9.

I believe that the allocation documentation is out of date; it states 
that the default allocator uses a pool, when in fact the default 
allocator is the new_allocator.

After reading libstdc++'s allocator documentation at 
http://gcc.gnu.org/onlinedocs/libstdc++/20_util/allocator.html I assumed 
that the default allocator uses a memory pool --- allocator.html states 
that "it's on by default."

However, I am not seeing the behavior I expect for the attached test 
program (derived from the allocator documentation).  The test program 
creates a linked list of 100 integers, allows that linked list to fall 
out of scope, and then creates another linked list of 100 integers.  
I've overloaded operator new and delete so that I can track their usage.

I expected to see fewer then 200 calls to operator new --- but I do.  I 
expected that setting the environment variable GLIBCXX_FORCE_NEW would 
change my output --- but it doesn't.  It all looks as if the default 
allocator is really the new_allocator; a brief look at the source code 
confirms that this is the case.

Switching to the other allocators gives me the results I expect --- 
fewer then 200 calls to operator new, and setting GLIBCXX_FORCE_NEW 
changes my program's output.

Have I misconfigured my compiler installation?  Is my installation 
broken?  Or is it just that the documentation is out of date?

Robert Zeh
http://home.earthlink.net/~rzeh
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: allocator2.C
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20050209/64711c52/attachment.ksh>


More information about the Libstdc++ mailing list