[MPlayer-dev-eng] Where to free loose memory?

D Richard Felker III dalias at aerifal.cx
Thu Sep 16 23:24:18 CEST 2004


On Thu, Sep 16, 2004 at 02:24:32PM -0500, Joey Parrish wrote:
> On Thu, Sep 16, 2004 at 02:57:34PM -0400, D Richard Felker III wrote:
> > On Thu, Sep 16, 2004 at 02:04:25PM -0400, The Wanderer wrote:
> > > Partly on the offchance that it would be useful and partly as a way to
> > > see and learn the code (in some more comprehensive way than the
> > > skim-over-while-changing-printfs I've done so far), I'm currently
> > > running mplayer inside valgrind in an attempt to track down and fix any
> > > memory leaks and so forth. (There are quite a number reported, but most
> > > seem to be problems in external libraries.) Note that I have no
> > > intention of submitting this work for actual use unless people indicate
> > > that such would be desirable; I'm not at all confident in my skills in
> > > such areas, this is mostly just a way for me to try to learn the code
> > > and get in a bit of practice in the process.
> > > 
> > > Is there any one canonical place, or group of places, where memory is
> > > supposed to be freed - one of the exit_* functions, perhaps - or should
> > > I just make my best guess as to a place which is after the final use of
> > > the variable in question?
> > 
> > freeing memory in exit_* functions is useless. if it's just a block of
> > memory allocated for the whole duration of the program, it never needs
> > to be freed. free is useful for things that can get allocated again
> > and again (and thus cause memory usage to keep growing if they're not
> > freed).
> 
> At least on *nix... who knows what windows memory management does...

even on dos there's no need to free your memory before exit... it all
exists in the process's heap, and the entire heap is obliterated when
the process exits.

rich




More information about the MPlayer-dev-eng mailing list