Discussion:
[Valgrind-users] some questions about valgrind massif
yoma sophian
2015-11-23 15:18:29 UTC
Permalink
hi all:
I have some questions about massif:
1. from massif.out file, I cannot tell where the free is called
I compile the sample code in the document page as below and get
the massif output. From the log, there are messages about where
"malloc" is called, but I cannot find the place for "free".
is there any option I need to add when using massif tool or config
I need to add when compile the valgrind?
( in the smple I attach, the line#28 is where "free" is called, but
there is no such information in the massif output)

2. there is a option call "--trace-children=yes" to capture all
children information.
is it possible to limit the specific child name for tracking?
if possile, should I use some other valgrind execution options or
modify the source code?

appreciate all your kind help in advance,
Azat Khuzhin
2015-11-23 15:33:19 UTC
Permalink
Post by yoma sophian
2. there is a option call "--trace-children=yes" to capture all
children information.
is it possible to limit the specific child name for tracking?
if possile, should I use some other valgrind execution options or
modify the source code?
...
--trace-children-skip=patt1,patt2..
...
--trace-children-skip-by-arg=patt1,patt2..
...
yoma sophian
2015-11-24 05:16:12 UTC
Permalink
Post by Azat Khuzhin
Post by yoma sophian
2. there is a option call "--trace-children=yes" to capture all
children information.
is it possible to limit the specific child name for tracking?
if possile, should I use some other valgrind execution options or
modify the source code?
...
--trace-children-skip=patt1,patt2..
...
--trace-children-skip-by-arg=patt1,patt2..
...
BTW, is there any other option that we can focus on some specific child?
Thanks for your kind help ^^
Philippe Waroquiers
2015-11-24 21:10:18 UTC
Permalink
Post by yoma sophian
1. from massif.out file, I cannot tell where the free is called
I compile the sample code in the document page as below and get
the massif output. From the log, there are messages about where
"malloc" is called, but I cannot find the place for "free".
is there any option I need to add when using massif tool or config
I need to add when compile the valgrind?
( in the smple I attach, the line#28 is where "free" is called, but
there is no such information in the massif output)
massif does not provide information about where memory was freed.
It shows the memory used by your program, and where it was allocated.

For what reason do you want to know where some memory was freed ?
Post by yoma sophian
appreciate all your kind help in advance,
You are welcome. Note that such type of questions is well suited
on valgrind-users. valgrind-developers is more used for questions
about valgrind development itself. So, no need to send the question
on both mailing lists.

Philippe
yoma sophian
2015-11-25 05:32:33 UTC
Permalink
hi philippe
Post by Philippe Waroquiers
massif does not provide information about where memory was freed.
It shows the memory used by your program, and where it was allocated.
For what reason do you want to know where some memory was freed ?
if there is no free information output by massif, how could
massif-visualizer show the heap memory usage decreased with thinner
color bar if some function call free?
(take the web side sample for example, the color of main in
massif-visualizer will get thinner at the end of UI output)
I cannot see any free information in the ms_print
Post by Philippe Waroquiers
You are welcome. Note that such type of questions is well suited
on valgrind-users. valgrind-developers is more used for questions
about valgrind development itself. So, no need to send the question
on both mailing lists.
Originally I thought maybe my question may nedd to modify source or
compile option.
Sorry for sending to 2 mailing lists ^^

BTW, I found the massif output seems only created when program exit.

is there any option or some modifification for valgrind to generate
massif.out in a period of time or by specific event, such as user add
special code in program or press specia button, etc?
Since I am using valgrind to profile a daemon heap usage when it
runing before and after some specific function, but
that mean I have to kill the daemon before and after running function.
And that is quite inconvinent.

thanks for your kind help,
Philippe Waroquiers
2015-11-25 20:37:05 UTC
Permalink
Post by yoma sophian
hi philippe
Post by Philippe Waroquiers
massif does not provide information about where memory was freed.
It shows the memory used by your program, and where it was allocated.
For what reason do you want to know where some memory was freed ?
if there is no free information output by massif, how could
massif-visualizer show the heap memory usage decreased with thinner
color bar if some function call free?
(take the web side sample for example, the color of main in
massif-visualizer will get thinner at the end of UI output)
I cannot see any free information in the ms_print
I do not know to what color bar you refer, but I guess that the decrease
of memory is detected by comparing 2 successive snapshots.
Massif records the stack trace of each malloc, and for each such
stacktrace, maintains the memory (still) allocated by this stack trace.
In other words, massif observes the free calls to decrease the memory
allocated by a stacktrace, but massif does not record the stacktraces
that are calling free, and does not maintain stats about such 'free
stacktraces'.

Maybe you could explain why you need to have the free stacktraces ?
This might maybe point at other tools (memcheck ? callgrind ? dhat ?)
that will help to achieve what you need/want.
Post by yoma sophian
Post by Philippe Waroquiers
You are welcome. Note that such type of questions is well suited
on valgrind-users. valgrind-developers is more used for questions
about valgrind development itself. So, no need to send the question
on both mailing lists.
Originally I thought maybe my question may nedd to modify source or
compile option.
Sorry for sending to 2 mailing lists ^^
BTW, I found the massif output seems only created when program exit.
is there any option or some modifification for valgrind to generate
massif.out in a period of time or by specific event, such as user add
special code in program or press specia button, etc?
Since I am using valgrind to profile a daemon heap usage when it
runing before and after some specific function, but
that mean I have to kill the daemon before and after running function.
And that is quite inconvinent.
You can trigger massif snaphots, using massif monitor commands either:
* from the shell, using vgdb
* from gdb, using gdb+vgdb
* from your program, using the client request
VALGRIND_MONITOR_COMMAND(command)

See
http://www.valgrind.org/docs/manual/ms-manual.html#ms-manual.monitor-commands
for the list of massif monitor commands.

Philippe
Philippe Waroquiers
2015-12-06 23:05:25 UTC
Permalink
I attach the pic, massif_test.png I got from massif-visualizer, and in
the pic, the heap allocated by main will decreased to 0.
But f and g these 2 functions will not.
What makes me curious is I cannot find the free information in the
massis output ascii file.
There is no free information in the massif outputs.
massif only produces a sequence of snaphots, each snapshot gives
the memory still allocated at the snapshot time.

The memory allocated by main returns to 0, because all the memory
allocated by main is freed. The graph effectively shows the absolute
value of the memory allocated at the snapshot time.
massif does not record the free stacktraces, it only records how
much memory is allocated by a stacktrace (and this amount decreases
when free is called).

So, in summary:
* massif does *not* record 'free' stacktraces
* massif *only* record 'malloc' stacktraces
* massif maintains the memory allocated by a stacktrace
this amount is decreased when free is called.

So, do not expect to find some details about free stacktraces, as these
are not recorded.
BTW, I have some questions about --pages-as-heap=yes
I purposely write a program, mmap.c, that will map the file into the memory
But from ms_print of mmap.c, mmap_4440, I cannot see the location of
mmap I put in the c file.
(I attach the c file and mass output as well)
Shall we add more options to see the location of mmap in the program
when enable --pages-as-heap=yes?
The stack is only output for detailed snaphots. I believe that no
detailed snapshot is taken between the mmap and the munmap.

I think there is a bug in the massif logic to make a peak detailed
snapshot at the moment of munmap: it should try to produce a peak
snapshot when releasing the first page of munmap, not when releasing
the last page.

Philippe
yoma sophian
2015-12-07 03:49:13 UTC
Permalink
Post by Philippe Waroquiers
There is no free information in the massif outputs.
massif only produces a sequence of snaphots, each snapshot gives
the memory still allocated at the snapshot time.
The memory allocated by main returns to 0, because all the memory
allocated by main is freed. The graph effectively shows the absolute
value of the memory allocated at the snapshot time.
massif does not record the free stacktraces, it only records how
much memory is allocated by a stacktrace (and this amount decreases
when free is called).
* massif does *not* record 'free' stacktraces
* massif *only* record 'malloc' stacktraces
* massif maintains the memory allocated by a stacktrace
this amount is decreased when free is called.
So, do not expect to find some details about free stacktraces, as these
are not recorded.
Thanks for your kind explination ^^
Post by Philippe Waroquiers
I think there is a bug in the massif logic to make a peak detailed
snapshot at the moment of munmap: it should try to produce a peak
snapshot when releasing the first page of munmap, not when releasing
the last page.
I use vgdb and try to create snapshop with command, "monitor
detailed_snapshot xxx"
No matter I create snapshop before mmap or after mmap, I hightlight in
the below program, there is still no mmap information in the detail
snapshop file.
It seems the mmap is not recorded by massif even I manual trigger the snapshop.
If I miss anything or do any wrong experiment, please let me know.

appreciate your kind help,

f();
g();
/****break Here*****/
p = mmap (0, sb.st_size, PROT_READ, MAP_SHARED, fd, 0);
if (p == MAP_FAILED) {
/****break Here*****/
perror ("mmap");
return 1;
}
Philippe Waroquiers
2015-12-07 21:48:09 UTC
Permalink
Post by yoma sophian
I use vgdb and try to create snapshop with command, "monitor
detailed_snapshot xxx"
No matter I create snapshop before mmap or after mmap, I hightlight in
the below program, there is still no mmap information in the detail
snapshop file.
It seems the mmap is not recorded by massif even I manual trigger the snapshop.
If I miss anything or do any wrong experiment, please let me know.
The mmap is probably below the massif threshold, and so is not shown.
Either mmap more memory or decrease the massif --threshold value.

Philippe
Philippe Waroquiers
2015-12-10 22:42:52 UTC
Permalink
Post by Philippe Waroquiers
I think there is a bug in the massif logic to make a peak detailed
snapshot at the moment of munmap: it should try to produce a peak
snapshot when releasing the first page of munmap, not when releasing
the last page.
revision 15745 introduces a test for this case, and fixes the bug.

Philippe



------------------------------------------------------------------------------
yoma sophian
2015-12-11 13:01:57 UTC
Permalink
Post by Philippe Waroquiers
Post by Philippe Waroquiers
I think there is a bug in the massif logic to make a peak detailed
snapshot at the moment of munmap: it should try to produce a peak
snapshot when releasing the first page of munmap, not when releasing
the last page.
revision 15745 introduces a test for this case, and fixes the bug.
I checkout 15745 and compile.
but I bump into below error message

valgrind.git# ./autogen.sh
running: aclocal
running: autoheader
running: automake -a
Makefile.am:21: error: required directory ./VEX does not exist
error: while running 'automake -a'
valgrind.git#

Did I miss anything?

thanks for your kind help,

------------------------------------------------------------------------------
Ivo Raisr
2015-12-11 14:57:25 UTC
Permalink
2015-12-11 6:42 GMT+08:00 Philippe Waroquiers <
Post by Philippe Waroquiers
Post by Philippe Waroquiers
I think there is a bug in the massif logic to make a peak detailed
snapshot at the moment of munmap: it should try to produce a peak
snapshot when releasing the first page of munmap, not when releasing
the last page.
revision 15745 introduces a test for this case, and fixes the bug.
I checkout 15745 and compile.
but I bump into below error message
valgrind.git# ./autogen.sh
running: aclocal
running: autoheader
running: automake -a
Makefile.am:21: error: required directory ./VEX does not exist
Why valgrind.git? Valgrind is versioned in SVN.
Anyway, it seems your source tree is incomplete and you did not get
an external repo 'VEX'. See
http://valgrind.org/downloads/repository.html

I,
yoma sophian
2015-12-11 15:00:10 UTC
Permalink
Post by Ivo Raisr
2015-12-11 6:42 GMT+08:00 Philippe Waroquiers
Post by Philippe Waroquiers
Post by Philippe Waroquiers
I think there is a bug in the massif logic to make a peak detailed
snapshot at the moment of munmap: it should try to produce a peak
snapshot when releasing the first page of munmap, not when releasing
the last page.
revision 15745 introduces a test for this case, and fixes the bug.
I checkout 15745 and compile.
but I bump into below error message
valgrind.git# ./autogen.sh
running: aclocal
running: autoheader
running: automake -a
Makefile.am:21: error: required directory ./VEX does not exist
Why valgrind.git? Valgrind is versioned in SVN.
Anyway, it seems your source tree is incomplete and you did not get
an external repo 'VEX'. See
http://valgrind.org/downloads/repository.html
I use git svn instruction for getting the repository.
it should be no differneces with git svn command.
Anyway, I will use svn command to redo again.

thanks for your kind remind,

------------------------------------------------------------------------------
yoma sophian
2015-12-13 12:43:13 UTC
Permalink
Post by yoma sophian
I use git svn instruction for getting the repository.
it should be no differneces with git svn command.
Anyway, I will use svn command to redo again.
hi ivo:
after I use svn instead of git svn, I can successfully compile valgrind trunk.
it seems git svn not handle external link ^^
Post by yoma sophian
Post by Philippe Waroquiers
Post by Philippe Waroquiers
I think there is a bug in the massif logic to make a peak detailed
snapshot at the moment of munmap: it should try to produce a peak
snapshot when releasing the first page of munmap, not when releasing
the last page.
revision 15745 introduces a test for this case, and fixes the bug.
hi Philippe:
I compile the trunk valgrind with ur patch, but I still cannot see the
location of mmap I put in the c file, even I set the --threshold=0.0.
(I attach the c file and mass output as well)
BTW, would you please let me know how to compile and run the programs
in massif/tests?

appreciate all your kind help,
Philippe Waroquiers
2015-12-13 13:36:52 UTC
Permalink
Post by yoma sophian
I compile the trunk valgrind with ur patch, but I still cannot see the
location of mmap I put in the c file, even I set the --threshold=0.0.
(I attach the c file and mass output as well)
--threshold indicates the threshold below which massif does not show
the details of the memory.
Details will be shown in 2 different kinds of snapshots:
* peak snapshots
* detailed snapshots

In your case, I guess that the file you are mmap-ing is too small to be
the peak, and you do not have a detailed snaphot being taken between
the mmap and the munmap.
E.g. try to mmap a much bigger file, to ensure that the peak is reached
by the mmap you are doing, and not any other operations.
Post by yoma sophian
BTW, would you please let me know how to compile and run the programs
in massif/tests?
in valgrind top directory, to compile/install locally and run all
regtests:

./configure --prefix=`pwd`/Inst
make install
make regtest

Philippe



------------------------------------------------------------------------------
Loading...