Mail Archives: djgpp/1998/12/09/14:29:06
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 -