The need to use memory in a C ++ function on Linux

I am looking for a runtime memory debugger capable of displaying memory usage (and not just leaks) for every function or line of C ++ code in Linux. I am trying to track a surge in my memory usage. I used Valgrind and Purify, and I found that there are no leaks. I expected that, after this surge, memory usage would return to the expected level for my program.

Thanks.

+4
source share
4 answers

You can use the array tool from the valgrind toolbox.

+3
source

The "Application Memory Analysis" section in Memory Usage Analysis provides a good overview and points to:

+1
source

I have used valgrind several times in the past, but if you want to catch where the spike occurs, I would use the following hack:

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

2) (assuming that your shared 4Gb drum) starts another user process that will allocate exactly 3Gb + 1 bytes and wait for you to press a key. Leave it waiting

3) run your application code and see where the memory allocation will not be allocated. Since your avialable memory is now slightly smaller than your SPIKE, when the spike occurs, it will not be able to allocate the requested memory

hope this helps

0
source

To get the use of function code size:

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

All Articles