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]

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



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