Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!aplcen!samsung!zaphod.mps.ohio-state.edu!wuarchive!decwrl!shelby!csli!poser From: poser@csli.Stanford.EDU (Bill Poser) Newsgroups: comp.unix.wizards Subject: Re: Program Memoryj Usage from 'C' Keywords: dynamic memory sbrk end Message-ID: <11438@csli.Stanford.EDU> Date: 14 Dec 89 08:14:17 GMT References: <601@h.cs.wvu.wvnet.edu> Sender: poser@csli.Stanford.EDU (Bill Poser) Reply-To: poser@csli.stanford.edu (Bill Poser) Followup-To: comp.unix.wizards Organization: Center for the Study of Language and Information, Stanford U. Lines: 15 The following occurs to me as a way of determining how much memory has been allocated dynamically, though I am not clear if the poster really wants to know about heap memory or stack memory. First, the sbrk system call, used to extend the processes' data region, returns the old value of the endpoint. So doing sbrk(0), asking for an extension of 0 bytes, should give you the current endpoint. Second, the external variables end, etext, and edata (see section 3 of the manual) contain the address one beyond the end of the processes uninitialized data, program text, and initialized data. So the amount of memory allocated on the should be: sbrk(0) - end + 1