
Description
MMPI (Memory Monitor Programming Interface) is a programming API for monitoring memory usage of a process.
Currently MMPI reports VmSize (the virtual memory size allocated for a process) and VmRSS (the real memory usage by a process). The library is implemented in C language, and it can be used in C/C++ and FORTRAN languages. This page provides examples to demonstrate how to use the library in different programming language environments, as well as with multi-threading and MPI.
VmSize and VmRSS are reported by reading /proc/self/status on a linux system.
- VmSize:
- Virtual memory size allocated for a process
- VmRSS:
- Real memory usage by a process
This is the number of KB the process has in real memory. This includes a small amount of memory necessary for administrative processes. This does not include pages which have not been demand-loaded in, or which are swapped out.
Use
Copy source vminfo.h vminfo.c from /nics/b/proj/nicsstaff/memory to your source code directory.
Functions:
- long long VmSize_self()
- returns VmSize in KBytes of calling process, -1 if fails
- long long VmSize(pid_t id)
- returns VmSize in KBytes of process with pid=id, -1 if fails
- long long VmRSS_self()
- returns VmRSS in KBytes of calling process, -1 if fails
- long long VmRSS(pid_t id)
- returns VmRSS in KBytes of process with pid=id, -1 if fails
Insert function calls into your program and link with vminfo object files, for example:
startvm = VmSize(getpid()); buf=malloc(10000*1024); endvm = VmSize(getpid());
There are serveral testing programs available:
- test: a sequential test program written in C.
- thread-test: a multi-threading test program written in C.
- mpi-test: a mpi test program written in C++.
- fmpi-test: a mpi test program written in fortran.
Support
For questions or assistance with Memory Monitor you can contact the author:
Haihang You at hyou@utk.edu
Contributors: Mark Fahey, Glenn Brook, Jeff Larkin, Min Zhou, Robert P Harkness

