如何确定 pthread 使用的内存

发布于 2024-12-01 19:13:30 字数 33 浏览 4 评论 0原文

任何给定的时间点,我如何获得每个线程使用的内存大小?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

红颜悴 2024-12-08 19:13:30

如果您想要的只是堆分析器,请考虑使用 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

溺深海 2024-12-08 19:13:30

不能,堆在进程中的所有线程之间共享。

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

巴黎盛开的樱花 2024-12-08 19:13:30

要检查线程的堆栈大小,您可以使用不可移植的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文