Whoami
Whoami

Reputation: 14428

How to determine the pthread utilized memory

Any given point of time, how can i get the memory size utilized by each thread?

Upvotes: 1

Views: 424

Answers (3)

tvn
tvn

Reputation: 634

To check the thread's stack size you could use non-portable GNU extension pthread_getattr_np and also you could check /proc/self/maps (or /proc/PID/maps) but this way is more complex.

Upvotes: 0

Steve-o
Steve-o

Reputation: 12866

If all you want is a heap profiler consider Google performance tools with their own allocator TCMalloc.

http://code.google.com/p/google-perftools/

An alternative high performance allocator is jemalloc which provides statistics reporting including per-thread cache bin details with malloc_stats_print()

http://www.canonware.com/jemalloc/index.html

Upvotes: 2

MK.
MK.

Reputation: 34597

You can't, the heap is shared between all threads in the process.

Upvotes: 2

Related Questions