Date: Fri, 18 Feb 2005 18:40:22 +0200 From: Andrey Simonenko <simon@comsys.ntu-kpi.kiev.ua> To: Ashwin Chandra <ashcs@ucla.edu> Cc: freebsd-hackers@freebsd.org Subject: Re: Memory Accounting in Proc.h Message-ID: <20050218164022.GA405@pm514-9.comsys.ntu-kpi.kiev.ua> In-Reply-To: <001001c5159c$8369aef0$abe243a4@ash> References: <001001c5159c$8369aef0$abe243a4@ash>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Feb 18, 2005 at 01:30:41AM -0800, Ashwin Chandra wrote: > I read up on getrusage which says that ru_idrss and ru_isrss are measured > in kilobytes * the number of clock ticks. So I wanted to retrieve the > actual value in just KB by using a timeval struct that gets the user > and system ticks and takes the structure fields and divides by this to > get Kb. (similar to how it is done in kern_acct.c). ru_utime and ru_stime are not measured in ticks, they are measured in sec and usec. getrusage() converts ticks to sec and usec by calcru(). > How can I accurately keep tabs of current memory usage per process? I don't believe that ru_idrss (which accumulates vm_dsize) can be used for true accounting of memory used by a process. For example memory can be mmap'ed, or not all pages can be used by a process even during all of its lifetime. Currently on my system there is one process with vm_dsize equal to 200M, but it always uses only 6M for private data and never touches the rest of its 194M. The same can be said for ru_isrss (which accumulates vm_ssize), but this value is more accurate. A better way is to walk through vm_map_entries and count number of pages, number of resident pages, etc... like procfs does.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050218164022.GA405>