Murat Alpman
Murat Alpman

Reputation: 21

Process Working Set Info in LINUX

I am trying to obtain the memory working set value for a given PID in my C++ application running on LINUX. In Windows I can get this info using GetProcessWorkingSetSize function. Is there anything like this function I can call in LINUX?

Upvotes: 2

Views: 1783

Answers (1)

Daniel Kamil Kozar
Daniel Kamil Kozar

Reputation: 19296

The only sensible solution that comes to mind is accessing the relevant information via the /proc filesystem. It seems weird that a process would have to read out its own information from /proc, though, but I don't know about any other system calls that might make this easier.

The information you're probably most interested in is located in /proc/[pid]/statm, which includes :

  • total program size,
  • resident set size,
  • shared pages,
  • text (code) size,
  • library (unused in Linux 2.6),
  • data and stack size,
  • dirty pages (unused in Linux 2.6).

Keep in mind that all those measurements are given in the number of pages.

Upvotes: 1

Related Questions