如何确定 pthread 使用的内存
任何给定的时间点,我如何获得每个线程使用的内存大小?
Any given point of time, how can i get the memory size utilized by each thread?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
任何给定的时间点,我如何获得每个线程使用的内存大小?
Any given point of time, how can i get the memory size utilized by each thread?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
如果您想要的只是堆分析器,请考虑使用 Google 性能工具他们自己的分配器TCMalloc。
http://code.google.com/p/google-perftools/
替代方案高性能分配器是 jemalloc,它通过
malloc_stats_print()
提供统计报告,包括每个线程缓存箱详细信息http://www.canonware.com/jemalloc/index.html
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
不能,堆在进程中的所有线程之间共享。
You can't, the heap is shared between all threads in the process.
要检查线程的堆栈大小,您可以使用不可移植的 GNU 扩展 pthread_getattr_np
你也可以检查/proc/self/maps(或/proc/PID/maps),但这种方式更复杂。
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.