I am trying to understand my embedded Linux application's memory use. The /proc/pid/maps
utility/file seems to be a good resource for seeing the details. Unfortunately I don't understand all the columns and entries.
What does the anonymous inode 0 entries mean? These seem to be some of the larger memory segments.
Each row in /proc/$PID/maps
describes a region of contiguous virtual memory in a process or thread. Each row has the following fields:
address perms offset dev inode pathname
08048000-08056000 r-xp 00000000 03:0c 64593 /usr/sbin/gpm
-
will appear instead of the r
/w
/x
. If a region is not shared, it is private, so a p
will appear instead of an s
. If the process attempts to access memory in a way that is not permitted, a segmentation fault is generated. Permissions can be changed using the mprotect
system call.mmap
), this is the offset in the file where the mapping begins. If the memory was not mapped from a file, it's just 0.[heap]
, [stack]
, or [vdso]
. [vdso]
stands for virtual dynamic shared object. It's used by system calls to switch to kernel mode. Here's a good article about it: "What is linux-gate.so.1?"You might notice a lot of anonymous regions. These are usually created by mmap
but are not attached to any file. They are used for a lot of miscellaneous things like shared memory or buffers not allocated on the heap. For instance, I think the pthread library uses anonymous mapped regions as stacks for new threads.