Is Valgrind Massif profiling itself with 7 KB of stack?

133 views Asked by At

I need to profile and trace used of stack of some program for my study, but I found that Valgrind Massif seems to profile itself with 7 KB of stack usage, how can I ignore it or is there any other profiler suitable for me?

it shows 7 KB of stack usage even execute nothing...

int main()
{
    return 0;
}

and the massif result:

--------------------------------------------------------------------------------
Command:            ./a.out
Massif arguments:   --stacks=yes --heap=yes
ms_print arguments: massif.out.29255
--------------------------------------------------------------------------------


    KB
7.008^                 #                                                      
     |                 #:                                                     
     |                 #:                                                     
     |                :#:                                                     
     |                :#:                                                     
     |                :#:                                                     
     |                :#:                                                     
     |                :#:                                                     
     |                :#:                                                     
     |                :#:                                                     
     |                :#:                                                     
     |                :#:  :                                                  
     |                :#:::::                                                 
     |                :#::@::                                                 
     |                :#::@::                                                 
     |                :#::@::                                                 
     |                :#::@::            ::  :::@:: : :::::  ::  :   ::::@  : 
     |                :#::@:::::::::::::::::::::@::@::::::::@:::@:::@::::@: : 
     |              :::#::@::::       ::::::::::@::@::::::::@:::@:::@::::@: : 
     |::::::::::::::@::#::@::::       ::::::::::@::@::::::::@:::@:::@::::@: :@
   0 +----------------------------------------------------------------------->ki
     0                                                                   135.7

Number of snapshots: 96
 Detailed snapshots: [2, 6 (peak), 11, 33, 38, 53, 63, 73, 83, 93]


1

There are 1 answers

2
phd On

Valgrind will by itself not change (much at least) the stack size used by the guest program.

What you see is very probably just the stack size used by the startup code: before main started to run, a whole lot of other things can happen.