From: Erik Max Francis 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: NNTP-Posting-Host: newton.alcyone.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk 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