I want to profile program for memory usage (both physical and virtual) per functions.
More precisely i've tried both valgrind and grof with no luck.
Is there for debian smth better?
I want to profile program for memory usage (both physical and virtual) per functions.
More precisely i've tried both valgrind and grof with no luck.
Is there for debian smth better?
What do you mean 'profile' memory usage?
All 3 functions use the same amount of memory (from one point of view at least).Code:void foo ( char *p ) { for ( i = 0 ; i < n ; i += 100 ) *p = 0; } void bar ( char *p ) { for ( i = 0 ; i < n ; i++ ) *p = 1; } int main ( ) { char *p = malloc(n); bar(p); foo(p); free(p); }
From another point of view, main doesn't use any, and foo uses only 1% of what bar uses.
Would cachegrind help?
Valgrind
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
By profiling memory usage i mean output like that:
<func_name> <mem allocated inside> <mem deallocated inside>
... ... ...
cachegrind? No, it's for simulating of processor cache (or at least i don't see, maybe i'm wrong?). Memcheck should do so, bt it isn't.
Now i'm trying to work with gperftools with no luck yet because it seems buggy
So for my example program
main.c:8 allocated n bytes
main.c:11 freed n bytes
And so on, for each unique block of allocated memory.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
what is about? valgrind --tools=cachegrind?
moreover i need tool to be able to print whole stack if memory changes even inside library (a static one with debug symbols).