delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/12/09/14:29:06

Sender: nate AT cartsys DOT com
Message-ID: <366ECDC4.B056B231@cartsys.com>
Date: Wed, 09 Dec 1998 11:21:40 -0800
From: Nate Eldredge <nate AT cartsys DOT com>
X-Mailer: Mozilla 4.08 [en] (X11; I; Linux 2.0.35 i486)
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: Allegro do_dialog causing memory leak?
References: <000a01be2303$2e21e580$b46f19c4 AT default>
Reply-To: djgpp AT delorie DOT com

StefanViljoen,6599 wrote:
> 
> Hi,
> 
> I have run into a quandry while using allegro's dialog procedures. I have
> noticed that
> a function that I had that called do_dialog seems to be leaking memory
> (exatly 8k 8192 bytes.) Since this function also creates and clears a linked
> list, I first suspected that I was leaving a node allocated, but this proved
> not to be the case - I traced the memory leak to the do_dialog.... Anybody
> else encounter this? Recursive calls to do_dialog (the dialog tested only
> contains the d_keyboard_proc dialog function) starts eating up memory until
> the system is constantly paging to disk.
> 
> I detected the leak by using go_32_remaining_physical_memory before and
> after the
> call to the dialog procedure. It reports the 8k discrepancy.

That's not reliable, since DJGPP's malloc/free don't return memory to
the DPMI server.  For example, try this:

void *p;
printf("%lu bytes remain\n", _go32_dpmi_remaining_physical_memory);
p = malloc(100000);
free(p);
printf("%lu bytes remain\n", _go32_dpmi_remaining_physical_memory);

and notice that the two are not equal.

So you will see that even if do_dialog frees all its memory.  A more
reliable way to check would be to investigate when `malloc' and `free'
are called and how, either by recompiling Allegro against some
memory-checking package like MSS, or by using the linker's `--wrap'
option.  Or, read Allegro's source.

-- 

Nate Eldredge
nate AT cartsys DOT com

- Raw text -


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