Memory leak!

Philip Herron herron.philip@googlemail.com
Fri Sep 11 04:55:00 GMT 2009


Brian McGrew wrote:
> Help, I¹ve got a memory leak and it¹s spilling all over the floor!
>
> LOL, I wish it was that simple...  I¹ve got several appliactions that all
> share the same Œcommon¹ memory and all rely on about 75 shared libraries out
> of my tree.  Somewhere I¹ve got a memory leak and I have no idea where to
> find it.  I¹m currently using gcc-4.1.3 on CentOS_x86-64 but the problem is
> exhibited on Fedora Core 5 with gcc-4.1.0
>
> This is the first time I¹ve ever been faced with finding a memory leak and
> I¹ve got no idea where to start or how to do it.  Please help!  I¹ve googled
> and found lots of stuff, but nothing that looks like it¹s directly
> applicable to finding a memory leak.  Also, I¹m restricted to whatever
> software is in the open, I have no commerical tools for this.
>
> Someone, PLEASE point me in the right direction!
>
> Thanks,
>
> -brian
>
>   
First thing i would say is calm down :)

It would be wise to have good experience in the language in which the 
application is written in. Memory leaks can be found using lots of 
different tools, my favorite is valgrind its very useful even using gdb 
you can start to see where your allocating memory and not freeing it. 
Make sure anything you allocate memory too when your not using it free 
it! You can check out dmalloc but its quite confusing to setup but its 
mean to be cool, but try valgrind first.

Problem being is if you application truly relies on over 75 shared 
libraries thats going to be painful but it would be wise to assume that 
they aren't the leaks and make sure your application is working perfect 
first. Then your going to have to start looking through those libraries. 
And make sure any use of those libraries you free their structures 
properly. We can't really help, one thing i would say is how did you 
know you have a memory leak might give you clues of where in the code 
its happening, you might want to get more familiar with memory management.

--Phil



More information about the Gcc-help mailing list