1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char* argv[]) {

    // MEMORY LEAK
    int* a = malloc(sizeof(*a) * 3);

    // because no free(…)

    return EXIT_SUCCESS;
}
/*
==26395== HEAP SUMMARY:
==26395==     in use at exit: 12 bytes in 1 blocks
==26395==   total heap usage: 1 allocs, 0 frees, 12 bytes allocated
==26395==
==26395== 12 bytes in 1 blocks are definitely lost in loss record 1 of 1
==26395==    at 0x4A06A2E: malloc (vg_replace_malloc.c:270)
==26395==    by 0x40057E: main (leak.c:7)
==26395==
==26395== LEAK SUMMARY:
==26395==    definitely lost: 12 bytes in 1 blocks
==26395==    indirectly lost: 0 bytes in 0 blocks
==26395==      possibly lost: 0 bytes in 0 blocks
==26395==    still reachable: 0 bytes in 0 blocks
==26395==         suppressed: 0 bytes in 0 blocks
*/
/* vim: set tabstop=4 shiftwidth=4 fileencoding=utf-8 noexpandtab: */

© Copyright 2017 Alexander J. Quinn         This content is protected and may not be shared, uploaded, or distributed.