Skip to content

Tag: procfs

can /proc/self/exe be mmap’ed?

Can a process read /proc/self/exe using mmap? This program fails to mmap the file: Answer You are making 2 mistakes here: Mapped size must be > 0. Zero-size mappings are invalid. You have to specify, if you want to create a shared (MAP_SHARED) or a private (MAP_PRIVATE) mapping. The following should work f…

Linux /proc/pid/smaps proportional swap (like Pss but for swap)

It seems (from looking at the Linux kernel source) that the Swap: metric in /proc/pid/smaps is the total swap accessible by the given pid. In the case where there is shared memory involved, this seems to be an over-approximation of actual swap usage. For example when summing swap usage of a parent pid with it…

thread level memory consumption of process

How do I get per thread based memory consumption of a process in Linux? I understand that we can use /proc/pid/task/tid/statm, but thats not helping my case. All the threads show same value and its same as PID’s statm. We can do valgrind but I am not looking for any invalid read/write or leaks. Valgrind…