UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

#1 2005-09-07 03:42 PM

lenna
Member
Registered: 2004-08-21
Posts: 77

Re: memory leak

Does anyone know of a function that helps to detect the amount of free memory I can use? I want to make sure I free all objects correctly.
thanks,
Lenna

Offline

#2 2005-09-07 04:32 PM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: memory leak

Most data allocation functions don't release all data when possible, so checking for free memory doesn't help much, other than to know that there is a leak or not, after running the program long enough.

For serious memory debugging use Valgrind or Mpatrol (repeating Rob here ;-), but in your case it's probably more useful to learn first more about proper memory usage and then just audit your code for bugs.

Offline

#3 2005-09-17 02:10 PM

dsmith
Member
Registered: 2005-09-17
Posts: 7

Re: memory leak

I've got to give a plug for Valgrind here.  First of all, I am a hack and not a professional programmer, so I tend to write pretty loose code.

That being said, it is amazing to run valgrind on something when you think that you have a tight ship.  In addition, valgrind is of immense help in tracking down those hard to find seg faults.

Maybe I am just a shoddy programmer (well, that is true...) but I think anyone would benifit from "valgrinding" their code.

Offline

#4 2005-09-17 06:26 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,847
Website

Re: memory leak

Offline

#5 2005-09-20 04:50 PM

duncang
Member
From: UK
Registered: 2004-04-30
Posts: 30

Re: memory leak

Offline

#6 2005-09-20 06:46 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,847
Website

Re: memory leak

Offline

#7 2005-10-01 05:40 PM

jfriesne
Administrator
From: California
Registered: 2005-07-06
Posts: 348
Website

Re: memory leak

Offline

Board footer

Powered by FluxBB