Search code examples
clinuxmultithreadingpthreadsprocfs

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 will not tell me any thread level info.

Any other suggestions?

EDIT: How do I profile my code? How much memory was allocated in which function/line number etc.?


Solution

  • All the threads share the same address space and use the same heap, so except for their stack, they should all show the same memory usage.