Hello,
is it possible to know how much memory is being used by a given phtread thread? I am interested by a VmRSS like information.
Hello,
is it possible to know how much memory is being used by a given phtread thread? I am interested by a VmRSS like information.
Each thread consumes a stack which is of fixed size and created when the thread starts. It is generally 512 K / 1M but it's only virtual size at startup.
However, for dynamically-allocated data (malloc), it's a process-wide information, not per-thread. Note that some alternative malloc implementations (like tcmalloc) could provide more advanced statistics.
In addition, the OS itself may free memory in a separate thread, to speed up calls to free() function, making gathering the correct statistics even more compilcated
From my own experience using the pthread library, if a thread is created with default attributes, then its stack size is 10 MB. It may be platform specific.
If you are interested in reducing the stack size, you can use the pthread_attr_setstacksize(). In order to estimate a proper value for the stack size, you can use a script called "checkstack.pl". It is shipped in the Linux Kernel sources (under the "scripts" directory).
See also http://www.kegel.com/stackcheck