开发者

Is there any way to know how much mem is used by a thread?

I am maintaining a pr开发者_高级运维ogram, and it use 600+MB mem when starting up, doing nothing!

I wanna know how much mem used by every thread, can gdb do this work?


valgrind --tool=massif is the right solution. It will give you all information which thread uses how much memory at what point of time.


I think a memory profiling tool like IBM/Rational Purify or valgrind might be what you need.

Also, if your program is using 600Mb on startup you should first check to see what your dependent libraries are doing once they get loaded. You may not have even entered main() yet but they might be creating some heavyweight global static objects which are initialized before things even get rolling.

Another thing to keep in mind is that each thread is going to get a lot of memory allocated to it for its stack. It might be a megabyte or more per thread, so if you create 600 threads yourself then there's 600Mb gone already.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜