delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/05/06/06:52:55

Date: Sun, 6 May 2001 13:54:05 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Rafal Maj <maj_rafal AT poczta DOT onet DOT pl>
cc: djgpp AT delorie DOT com
Subject: Re: Counting allocated memory
In-Reply-To: <9d33ak$gbv$1@info.cyf-kr.edu.pl>
Message-ID: <Pine.SUN.3.91.1010506134501.6726A-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

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 -


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