How to get memory information on a Linux system?

How to get shared memory, used memory, free memory from C ++ code on Linux system?

0
source share
2 answers

Run the program through valgrind. For a program called foo, for example:

valgrind foo

It will run a wiring program that monitors memory usage and prints this information after the program finishes.

If you do not have it installed valgrindfor any reason, you can find it in your distribution package repository.

0
source

Chris Stratton, - Linux - /proc/, proc (5); (, ), . , . .

, /proc/self/maps - /proc/self/smaps; , pid 1234, /proc/1234/maps /proc/1234/smaps; /proc/meminfo

:

cat /proc/meminfo
cat /proc/$$/maps
cat /proc/$$/smaps
cat /proc/self/maps

, .

, malloc free ( new delete) ( ) , mmap (2), free -d , ​​ munmap. wikipage C . , ( , malloc -s, mmap -ed). . mallinfo (3) malloc_stats (3).

, valgrind .

Linux - . .

0

All Articles