# Finding memory use in procfs?



## paulehoffman (Feb 19, 2015)

Greetings again. I want to see how much memory is being used by the current process. That doesn't seem to be one of the items in /proc/curproc/status, and I'm not sure if I can read /proc/curproc/map correctly to see how much memory total is being used. Is this available in some consistent place (other than top(1))?


----------



## junovitch@ (Feb 19, 2015)

I'm traveling and don't have a Linux box available to confirm this, but does `procstat -r <PID>` show you what you need?  General procstat(1) is the tool to get information about processes that you would get through /proc on Linux.


----------



## paulehoffman (Feb 20, 2015)

I'm assuming "Linux" is a typo because the forum is for FreeBSD (and there is no procstat on Linux). Still, I'm not seeing a value in
`procstat -r`
that is "the total memory used by this process".


----------



## junovitch@ (Feb 20, 2015)

Sorry about that, I've answered a couple questions on a FreeBSD equivalent for what is in a Linux /proc and my mind stuck "Linux" into your questions as I read it.  The `procstat -r <PID>` shows RSS which matches RES in `top`.  Are you just looking for what's under the size column?  There might be a ps(1) flag for that.


----------



## tobik@ (Feb 20, 2015)

You can use ps(1) to get individual columns you see in `top`: `ps -o rss,pmem,vsize $pid`


----------



## paulehoffman (Feb 20, 2015)

junovitch said:


> The `procstat -r <PID>` shows RSS which matches RES in `top`.



Er, no, `procstat` it shows maximum RSS, which doesn't change after memory is freed and `top` shows lower memory use.



junovitch said:


> Are you just looking for what's under the size column?  There might be a ps(1) flag for that.


----------



## paulehoffman (Feb 20, 2015)

tobik said:


> You can use ps(1) to get individual columns you see in `top`: `ps -o rss,pmem,vsize $pid`



Thanks, that looks exactly right.


----------



## Beeblebrox (Feb 20, 2015)

You might like this nifty perl script. Save it as ~/bin/free and make it executable (obviously).


----------

