I would like to get some information about the memory usage of my C++ program. The way I do this is by accessing /proc/self/stat
and printing the virtual and resident set size.
You can find an example here.
Is this a good way to go? How accurate is the information I am accessing*?
Could someone recommend a better way to measure memory usage programmatically?
*Asking, because I get unexpected, sudden jumps of mem usage. My expectation was that the information is perfectly accurate.
OS: I am running inside a docker container, which is based on RHEL.
Additional info: If I limit the memory usage of the container with docker run -m
, the printed memory is greater than the limit I set.