Problem with allocator in a multithreaded application.

Nathan Zorn nzorn@d2.com
Tue May 25 00:41:00 GMT 2004


Yes, I built it with the -pthread option for both linking and compiling.

I built the test application with g++ -pthread stl_vector.C -o stl_vector.

The only other switched I used with compiling and linking my larger 
application
was the -O3 option to turn on all the optimizations.  I also tried 
different levels
down to no optimization, but they all have the same memory issue.

lrtaylor@micron.com wrote:

>Just a shot in the dark, but did you build it with the -pthread option
>(for both compiling and linking)?
>
>Thanks,
>Lyle
>
>-----Original Message-----
>From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On
>Behalf Of Nathan Zorn
>Sent: Monday, May 24, 2004 5:58 PM
>To: gcc-help@gcc.gnu.org
>Subject: Problem with allocator in a multithreaded application.
>
>Maybe this should go to libstdc++, but I will try this list first.   I 
>am developing a multithreaded
>application that uses a lot of the std containers and streams.  Since 
>the platform  I am developing
>for is redhat 7.2 , I initially used the compiler that is shipped with 
>that distribution (2.96).  This
>version had its problems, so I decided to start using gcc version 3.3.2 
>(the latest at the time).  I
>built this version with only the --enable-threads configure switch.   I 
>released a stable version of
>my application with this build.   Recently I switched development 
>machines and attempted
>to rebuild the gcc compiler (again only with --enable-threads configure 
>option).  Ever since this rebuild my application has had strange memory 
>leak problems.  It will run for awhile then consume all
>the machines memory resources.  This is the same version of my code that
>
>ran fine before and
>the same version of gcc (only rebuilt on the new machine).  Since this 
>version of gcc didn't work
>I also tried gcc 3.4.0 with the same result.  I have ran this 
>application through valgrind with
>no reports of problems except in the std::allocator code.  I found this 
>in the FAQ which explains that it isn't a leak but just the behavior of 
>the basic allocator.  So, I created a small application [1] that when it
>
>is run through valgrind single threaded its fine, but multithreaded it 
>definitely
>seems to leak memory.  Also in order to elliminate that it is my code, I
>
>built my application
>with the Intel compiler and the memory leak didn't occur, even after 
>three days of running.
>
>
>Any suggestions and help is appreciated.  I really don't want to start 
>using the intel compiler instead of gcc.
>
>Thanks
>
>[1] http://bfs.itlab.musc.edu/~nathan/stl_vector.C
>
>
>  
>



More information about the Gcc-help mailing list