Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Dec 2010 22:51:02 +0100
From:      Claus Guttesen <kometen@gmail.com>
To:        freebsd-stable@freebsd.org
Subject:   get ram usage using getrusage()
Message-ID:  <AANLkTi=6rnad2fWcL444BZBK6PzHFRNkf-F3uvEbEAC6@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
Hi.

I'm trying to read how much ram an app is using reading
http://unix.derkeiler.com/Mailing-Lists/FreeBSD/stable/2006-03/msg00246.html
from ru.ru_maxrss. While ru.ru_maxrss gives me used accurate ram-usage
when memory increases it doesn't immediately count down when memory is
released.

So I tried to get a more accurate reading using this using
/usr/src/sys/kern/kern_clock.c as example:

struct thread *td;
td = curthread;
p = td->td_proc;
vm = p->p_vmspace;
rss = pgtok(vmspace_resident_count(vm));

Curthread is not defined, I searched google but can't find any references.

But is this the proper way to get an apps memory usage?

-- 
regards
Claus

When lenity and cruelty play for a kingdom,
the gentler gamester is the soonest winner.

Shakespeare

twitter.com/kometen



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTi=6rnad2fWcL444BZBK6PzHFRNkf-F3uvEbEAC6>