/proc/$pid/maps
shows pages with no rwx permissions on x86_64 linux.
I noticed that when I read /proc/$pid/maps
at 64bit linux I have memory pages that have no permissions, but in a 32bit linux, they aren't there.
I’m trying to monitor the memory usage of my process, but Im confused. Why are there pages with no rwx privileges. They are consuming my memory!
This is a snippet of the output of a 64bit linux for ‘top’
% cat /proc/21367/maps
3154200000-315420d000 r-xp 00000000 fd:00 4835776 /lib64/libproc-3.2.7.so <br/>
315420d000-315440d000 **---p** 0000d000 fd:00 4835776 /lib64/libproc-3.2.7.so <br/>
315440d000-315440e000 rw-p 0000d000 fd:00 4835776 /lib64/libproc-3.2.7.so
please advise.
These mappings are used for shared libraries:
In general for each shared library loaded we will have four mappings:
The first one is the code segment with executable permissions, the second one the PROT_NONE (no permissions) mapping, and the last two ones the data segment (read only part and read write).
The PROT_NONE mappings are created to do with keeping libraries efficiently sharable and to mark guard pages so buffer overflows can be catched.
Just keep in mind that these mappings are only using part of the virtual address space but they are not actually consuming the systems memory.
Here you can find a complete explanation:
http://www.greenend.org.uk/rjk/tech/dataseg.html