开发者

Need Memory Usage Tool per C++ function on Linux

I'm looking for a runtime m开发者_C百科emory debugger, capable of showing memory usage (not just leaks) per function or line of C++ code on Linux. I am trying to track down a spike in my program memory usage. I have used Valgrind and Purify and I found that there are are no leaks. I expected that, as after that spike, the memory usage gets back to its expected level for my program.

Thanks.


You can use the massif tool from the valgrind pack of tools.


The section "Application memory analysis" in Memory usage analysis gives a nice overview and points to:

  • memprof
  • kmtrace
  • Valgrinds Massif


i've used valgrind a few times on the past, but if you want to catch where the spike is happening, i would use the following hack:

1) measure the size of the spike (suppose SPIKE = 1Gb)

2) (assuming your total ram is 4Gb) run a different custom process that will allocate exactly 3Gb + 1 byte, and wait until you press a key. Leave that on hold

3) run your application code and see where your memory allocation will fail. Since your avialable memory is now slightly less than your SPIKE, when the spike happens, it will be unable to allocate the requested memory

hope it helps


To get the function code size usage:

nm --demangle --print-size --size-sort --reverse-sort <your exec built with -g> 
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜