I cannot find a source of total physical memory usage for all userspace processes on Linux.

I want to measure a memory usage of a complex application, which consists of many sub-applications (many processes and RDBMS). I’d like to record the development of memory usage of all processes in current Linux OS instance during the application runtime. I am interested in physical or if not possible in resident memory consumption (RSS in top or PSS - PrivateRSS + SharedRSS/number of processes). There is no other application or processes running on the host (their memory usage is negligible).

Differently from other similar questions, the answer may be derived from the additional information that Linux guest is running inside of a VMWare container (this can be used to obtain the memory statistics).

It is not possible to enumerate all application processes, because there too many of them and their lifetime sometimes is very short.

Ideally, I want to get peak memory usage directly, without sampling, since I afraid to miss the peak.

My first guess is to take /proc/meminfo and use MemTotal – MemFree = CurrentMemoryUsage, but I also afraid that it is incorrect, because the memory can be also claimed by Linux kernel, e.g. for file caching, and will also be recorded as used memory. This method is also not accurate in estimating the peak memory usage.

Using time or /proc//smaps is not possible, because there are too many independent processes in the application and they runtime can be very short.

  • Task is complex and I assume there is no method of calculation 'exact' value. Maybe you find it helpful: kernel.org/doc/Documentation/cgroup-v1/memory.txt (5.2. stat file). – Yurij Goncharuk Apr 4 '18 at 13:58
  • /proc/[PID]/... should have the information for one [PID] and you will have no choice but to track PID from your app and add them all. Else a really simple though not precise way to do it is to install atsar let your computer idle for 10 minutes then run your app when your app stop let your computer idle for 10 minutes. atsar would allow you to find cpu memory difference between idle and busy computer. – Kiwy Apr 4 '18 at 14:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.