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]

Re: mt_allocator allocates excessively


> The gist of the problem we are having is that our application is
> consuming way too much memory. Using valgrind/massif, I saw that
> __gnu_cxx::__mt_alloc was allocating 32,768 or 81,940 bytes when the
> desired allocation is in the hundreds of bytes. I then wrote a test
> program to demonstrate the behavior, the source is below. Of course,
> using the environment variable GLIBCXX_FORCE_NEW I was able to get
> memory consumption back to a reasonable level. I suspect something is
> wrong with our toolchain or its configuration. Further, I think it
> may have something to do with pthreads. Can anyone point me to docs
> that describe the proper way to enable pthread support for libstdc++?

The documentation for threads is admittedly quite weak, but what exists
and is current is here:
http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt01ch03s05.html#manual.intro.using.concurrency.thread_safety

Please note that you are using (at this point) a pretty old version of
gcc (3.4) and that these docs are against the current version (4.3). 

It would be helpful if you could test against 4.3 and see if this
behavior is still the same, and if so please enter a bug report in gcc
bugzilla in the libstdc++ category.

> The g++ manual says to use -pthread on various platforms, though not
> i386 et.,al. We are using it and g++ is not complaining. I appreciate
> any help.

You need to use -pthread on linux.

-benjamin


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