chen-dahe@CS.Yale.EDU (Dahe Chen) (03/29/89)
Can anyone tell me a way to find out hwo much memory a C program is using at a certain point. I tried with dbx and ps. It seems ps only gives the maximum size of memory ever used. Am I right? ------- Dahe Chen internet: dchen@twolf.ce.yale.edu ( @venus.ycc.yale.edu ) chen-dahe@cs.yale.edu bitnet: dchen@yalevms
perrone@loligo.uucp (Perrone Ford) (03/29/89)
I think TOP may give an accurate account of how much memory a program is using at a given time...although it has the nasty side effect of hogging system memory itself. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Perrone T. Ford | Bitnet : PFord@FSU.Bitnet % % arpa: Perrone@loligo.com.fsu.edu | ford@systems.fsu.edu % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
gwyn@smoke.BRL.MIL (Doug Gwyn ) (03/29/89)
In article <55125@yale-celray.yale.UUCP> chen-dahe@CS.Yale.EDU (Dahe Chen) writes: >Can anyone tell me a way to find out hwo much memory a C program is >using at a certain point. I tried with dbx and ps. It seems ps only >gives the maximum size of memory ever used. Am I right? This is apparently a UNIX-specific question and really has little to do with C. On UNIX, a process typically has a fixed amount of "text" (instruction) space, a variable (fixed on some architectures) amount of stack space for activation records, a fixed amount of preinitialized data space, and a variable amount of "heap" (dynamic) memory space. The latter is where memory assigned by the C library malloc() routine comes from. When a process needs more dynamic memory, it requests that its heap space be grown by the operating system, via a sbrk() or brk() system call. (malloc() does that when necessary.) There is really no notion of how much of the current heap space is "used" or "unused"; it is all available to your process. That's what is reported by "ps" etc.