get ram usage using getrusage()
Jeremy Chadwick
freebsd at jdc.parodius.com
Mon Dec 20 00:30:51 UTC 2010
On Sun, Dec 19, 2010 at 10:51:02PM +0100, Claus Guttesen wrote:
> 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?
This question might be better suited for the freebsd-hackers mailing
list.
--
| Jeremy Chadwick jdc at parodius.com |
| Parodius Networking http://www.parodius.com/ |
| UNIX Systems Administrator Mountain View, CA, USA |
| Making life hard for others since 1977. PGP 4BD6C0CB |
More information about the freebsd-stable
mailing list