This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Custom allocator for vector and libstdc++-v3


Hi,

I have asked the question below in news:comp.std.c++
at http://groups.google.com/groups?selm=2ns6efF45gptU1%40uni-berlin.de.

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:
http://groups.google.com/groups?threadm=2nrba8F3sq7sU1%40uni-berlin.de

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.


-- 
   Alex Vinokur
     http://mathforum.org/library/view/10978.html
     http://sourceforge.net/users/alexvn




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]