Mail Archives: djgpp/2001/05/06/06:52:55
On Sun, 6 May 2001, Rafal Maj wrote:
> I have question about allocating memory. In DJGPP, is there somewhere
> information about all blocks of memory that have been allocated and still
> wheren't freed ?
It's kept internally by malloc and sbrk. For the former, see the source
file malloc.c in the library source distribution djlsr203.zip. For the
latter, you can use the docs of the function __djgpp_memory_handle and
the source file memhandl.c.
> If not, then can I get exacly number of allocated bytes ?
Please tell the details--what does ``exactly number of allocated bytes''
mean? Memory allocation happens in at least two stages: first, `sbrk'
requests memory from the DPMO host in large chunks, then it subdivides
those chunk into smaller pieces and hands them to `malloc'. `malloc'
then maintains its own list of allocated and free memory in its internal
data structures.
Which part of this is ``exactly number of allocated bytes''?
> It can be very useful for debugging purpose...
What debugging purposes did you have in mind? If you are looking for a
way to find memory leaks, there are packages that will let you do that
without messing with the internals of `malloc'. See section 22.4 of the
DJGPP FAQ list for some pointers.
- Raw text -