I want to measure memory usage for each thread within process. Is it possible? I’m trying to figure out which thread leaks memory.
Edit 1.
The pmap for leaking process shows ~600 allocation by [ anon ]
...
63b00000 772K rw--- [ anon ]
63bc1000 252K ----- [ anon ]
63c00000 772K rw--- [ anon ]
63cc1000 252K ----- [ anon ]
63d00000 772K rw--- [ anon ]
...
Advice on what to do next?
Edit 2.
Only virtual memory is leaking e.g. physical memory usage is stable.
No this isn’t possible, because memory isn’t attached to a thread but to the process. There is no link between a thread and some part of the memory.
What you seem to need is a profiler, which would point to the allocation points. One of them (didn’t use it in the last decade) is Rational Purify.