This is the mail archive of the
mailing list for the libstdc++ project.
Custom allocator for vector and libstdc++-v3
- From: "Alex Vinokur" <alexvn at connect dot to>
- To: libstdc++ at gcc dot gnu dot org
- Date: Mon, 16 Aug 2004 08:05:45 +0300
- Subject: Custom allocator for vector and libstdc++-v3
I have asked the question below in news:comp.std.c++
But I have no response.
Different compilers produce quite different behavior with the same custom allocator.
Here is the Nicolai M. Josuttis' allocator code sample (for vector) with cosmetic changes added by me to profile the executable:
Here are run log files for the following compilers
* GNU g++ : http://groups.google.com/groups?selm=2nrb31F3q19kU1%40uni-berlin.de
* Microsoft C++ : http://groups.google.com/groups?selm=2nrbdaF3orecU1%40uni-berlin.de
* Borland C++ : http://groups.google.com/groups?selm=2nrbe9F3ta94U1%40uni-berlin.de
We can see that
* GNU g++ 3.3.1 doesn't invoke construct() and destroy();
* Microsoft C++ 13.00 and Borland C++ 5.5.1 do invoke construct() and destroy().
We can see also that behavior of Microsoft C++ 13.00 and Borland C++ 5.5.1 is quite different;
for instance, Borland C++ allocates memory for 256 elements, Microsoft C++ allocates memory for small number of elements.
So, behavior of a custom allocator is significantly compiler-dependent.
The question is what can one achieve using a _custom_ allocator?
The more specific question: do we need construct() and destroy() indeed? For instance, g++ doesn't use them.