Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!wuarchive!udel!haven!h.cs.wvu.wvnet.edu!b.cs.wvu.wvnet.edu!dymm From: dymm@b.cs.wvu.wvnet.edu (David Dymm) Newsgroups: comp.unix.wizards Subject: Program Memoryj Usage from 'C' Message-ID: <601@h.cs.wvu.wvnet.edu> Date: 13 Dec 89 13:44:06 GMT Sender: news@h.cs.wvu.wvnet.edu Lines: 28 I want to know exactly (or close to it) how much memory has been allocated by a 'C' program. Thus, I want to make a call from athe running program to determine how much memory the program has currently allocated on the stack. I tried using "ps". Thus I used sprintf (buffer, "ps -auxw | grep %d | grep -v grep > outfile", pid_number); system (buffer); where "pid_nubmer" is the pid number of the process. I then pulled out the string from "outfile" and parsed it to the correct field ("sz") to get the memory allocated on the stack and data segment. But this does NOT give consistent results and in fact sometimes gives very odd results. Such as telling me that a program has allocated only 8 kb when I know it has allcoated over 30kb. Is there a better way?? Is there a direct 'C' cal that I can make to unix to give me the memory allocated on the stack?? David Dymm Software Engineer USMAIL: Bell Atlantic Knowledge Systems, 145 Fayette Street, Morgantown, WV 26505 PHONE: 304 291-2651 (8:30-4:30 EST) USENET: {allegra,bellcore, cadre,idis,psuvax1}!pitt!wvucsb!dymm INTERNET: dymm@b.cs.wvu.wvnet.edu