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
source share