Mail Archives: djgpp/1998/02/03/21:27:50
At 04:35 2/3/1998 GMT, Erno Tuomainen wrote:
>
> Are there any methods to check the memory amount allocated by my
>program? Under DJGPP/CWSDPMI.
>
> It would be nice to be able to check the memory usage with a single
>keypress inside my program.
>
> This would help a lot while developing some programs which
>allocate/free mem a lot.
Well, yes, but I think it will not quite do what you want. See the function
`__dpmi_get_free_memory_information'. However, this reports only the amount
of memory the DPMI server has available. When you `malloc' a block, `malloc'
may take more memory than you asked for, for reasons of efficiency.
Furthermore, `free' does not actually return memory to the DPMI system, but
only keeps it available for further `malloc's. So it will not help you find
memory leaks, etc. The usual method is to write a wrapper around
`malloc'/`free' which keeps track of all that.
Nate Eldredge
eldredge AT ap DOT net
- Raw text -