开发者

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 f开发者_如何学Pythonunction/line number etc.?


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.


There is an option in Linux to see the thread level usage of cpu and memory

You can use command top with option -H and -p

top -H -p<PID>

Command will list the result with following header and you should read PID as TID(Thread id) in this case.

PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND`

In case of java process it is quite obvious as follows. If you create a thread dump of a process and convert the thread id to decimal you can match with the TID listed in output of top -H -p <PID>

For

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜