This is the mail archive of the
mailing list for the libstdc++ project.
Re: mt_allocator allocates excessively
- From: Benjamin Kosnik <bkoz at redhat dot com>
- To: David Weidenkopf <dweidenkopf at cococorp dot com>
- Cc: "libstdc++ at gcc dot gnu dot org" <libstdc++ at gcc dot gnu dot org>
- Date: Tue, 6 May 2008 10:31:36 -0500
- Subject: Re: mt_allocator allocates excessively
- References: <FDC9423C31BF1C4DBCFDA8F1BF8C15C02146FE526D@EXMBX04.exchhosting.com>
> 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:
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.