delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/18/03:02:33

From: Erik Max Francis <max AT alcyone DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: How can I detect memory leaks?
Date: Fri, 17 Oct 1997 20:44:37 -0700
Organization: Alcyone Systems
Lines: 24
Message-ID: <344830A5.74DC3382@alcyone.com>
References: <Pine DOT LNX DOT 3 DOT 95 DOT 971014205100 DOT 21018A-100000 AT olvs>
NNTP-Posting-Host: newton.alcyone.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Alex Baldin wrote:

>   Is there in DJGPP some like `coreleft' in Borland C ? If not, how
> can I detect memory leaks in my program?

Using library calls to check how much memory is left often is not
helpful, because 1. it is nonportable and 2. in some memory models,
memory freed by a process is not actually released until the program
exits.  In the latter case, the "coreleft" (or equivalent) function will
not give you the right answer.

The safest, most portable, and easiest-to-control way is to make
wrappers around malloc/free or new/delete, so that you can monitor what
is being allocated and freed.  And in that case, all you need to do is
periodically check if there are any unaccounted-for outstanding
allocations.

-- 
          Erik Max Francis, &tSftDotIotE / mailto:max AT alcyone DOT com
                        Alcyone Systems / http://newton.alcyone.com/
   San Jose, California, United States / icbm://+37.20.07/-121.53.38
                                      \
   "After each war there is a little / less democracy to save."
                                    / Brooks Atkinson

- Raw text -


  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019