hi Philippe:

> 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.
Thanks for your kind explination ^^

>
> 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;
        }

Attachment: mmap_snap_0
Description: Binary data

Attachment: mmap_snap_1
Description: Binary data

Attachment: mmap_snap_2
Description: Binary data

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
void g(void)
      {
	int* test1;
         test1 = malloc(4000);
      }

      void f(void)
      {
	int* test2;
         test2 = malloc(2000);
         g();
      }
int main (int argc, char *argv[])
{
        struct stat sb;
        off_t len;
        char *p;
        int fd;

        if (argc < 2) {
                fprintf (stderr, "usage: %s <file>\n", argv[0]);
                return 1;
        }

        fd = open (argv[1], O_RDONLY);
        if (fd == -1) {
                perror ("open");
                return 1;
        }

        if (fstat (fd, &sb) == -1) {
                perror ("fstat");
                return 1;
        }

        if (!S_ISREG (sb.st_mode)) {
                fprintf (stderr, "%s is not a file\n", argv[1]);
                return 1;
        }
	f();
	g();
        p = mmap (0, sb.st_size, PROT_READ, MAP_SHARED, fd, 0);
        if (p == MAP_FAILED) {
                perror ("mmap");
                return 1;
        }

        if (close (fd) == -1) {
                perror ("close");
                return 1;
        }
        for (len = 0; len < sb.st_size; len++){
                putchar (p[len]);
	}
	printf("\n");
        if (munmap (p, sb.st_size) == -1) {
                perror ("munmap");
                return 1;
        }

        return 0;
}
------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to