This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
std::string allocator
- From: "Stefan Olsson" <stefan at garcio dot com>
- To: libstdc++ at gcc dot gnu dot org
- Date: Mon, 06 Mar 2006 16:20:48 +0100
- Subject: std::string allocator
Hi folks,
back with a new allocator related issue. Downloaded 4.1.0 and compiled with:
--enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --host=i386-redhat-linux --enable-libstdcxx-allocator=mt --enable-languages=c,c++
This way I can enjoy the performance of mt_alloc without having to specify it every time (or rather set up a global define for each type). Not quite though...
...the std::string is defined in bits/stringfwd.h as:
typedef basic_string<char> string;
I kind of expected it to look something like this in order to use the same allocator as the rest of the containers:
typedef std::basic_string<char, std::char_traits<char>, __glibcxx_base_allocator<char> > string;
Am I not thinking sane here? A quick hack from my side (in the current application that I'm working on) showed that this is indeed the reason for my "memory leak" - this is just like the original reason for developing this allocator; when multiple threads allocate and deallocate (at least on Linux) they tend to eat up a lot of memory...
Brgds