Mail Archives: djgpp/1998/08/27/03:47:44
From: | sparhawk AT eunet DOT at (Gerhard Gruber)
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: memory leaks
|
Date: | Thu, 27 Aug 1998 07:38:22 GMT
|
Organization: | EUnet Austria
|
Lines: | 39
|
Message-ID: | <35e68e06.688031@news.Austria.EU.net>
|
References: | <01bdd13a$6597d6c0$50c3b8cd AT scully>
|
NNTP-Posting-Host: | e079.dynamic.vienna.at.eu.net
|
Mime-Version: | 1.0
|
NNTP-Posting-Date: | 27 Aug 1998 07:40:00 GMT
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Destination: "Cephaler" <cephaler AT hotmail DOT com>
From: Gruber Gerhard
Group: comp.os.msdos.djgpp
Date: 26 Aug 1998 21:42:48 GMT:
> I've just finished a good sized chunk of code for my game, and it uses
>lots and lots of pointers. I know from past experiences that memory leaks
>make programs crash (over time?) But this one seems to be ok.. I figure
>since it's a memory 'leak' (I don't really know what a leak is, a pointer
>that's wasn't freed?) I'd go check mem(the dos command) to see if any of
>the values changed, but I began to wonder if windows hides some values from
>command.com.. Is there a quick way to see if you've got a memory leak?
When I suspect something of this, I usually replace all call to malloc() with
a macro MALLOC and define this macro to write to a logfile. Same for free() of
course. Then you can wordcount the number of times you called malloc and free.
If they are the same it's usually ok unless you didn't use realloc (I usually
don't). Of course you don't need to write to a file you can also use a static
variable where you count each malloc/free and check it with a debugger or a
printf on exit or something. If there is a better way, I'd glad to hear about
it, though. :)
--
Bye,
Gerhard
email: sparhawk AT eunet DOT at
g DOT gruber AT sis DOT co DOT at
Spelling corrections are appreciated.
- Raw text -