Date: Sun, 6 May 2001 13:54:05 +0300 (IDT) From: Eli Zaretskii X-Sender: eliz AT is To: Rafal Maj cc: djgpp AT delorie DOT com Subject: Re: Counting allocated memory In-Reply-To: <9d33ak$gbv$1@info.cyf-kr.edu.pl> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 Precedence: bulk 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.