Vérification de fuite mémoire :
$ cat -b allocfree.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #define NB_CHAINES 10
4 #define MAX_CHAINE 1024
5 int main(void){
6 char **tab=malloc(NB_CHAINES*sizeof(char *));
7 int i;
8 for(i=0;i<NB_CHAINES;i++){
9 tab[i]=malloc(MAX_CHAINE*sizeof(char));
10 sprintf(tab[i],"%d",i);
11 }
12 for(i=0;i<NB_CHAINES;i++)
13 printf("%s\n",tab[i]);
14 return 0;
$ valgrind --leak-check=full ./allocfree
==5405== Memcheck, a memory error detector
...
==5405== HEAP SUMMARY:
==5405== in use at exit: 10,280 bytes in 11 blocks
==5405== total heap usage: 11 allocs, 0 frees, 10,280 bytes allocated
==5405==
==5405== 10,280 (40 direct, 10,240 indirect) bytes in 1 blocks are definitely lost in loss record 2 of 2
==5405== at 0x4028308: malloc (vg_replace_malloc.c:263)
==5405== by 0x8048491: main (allocfree.c:6)
==5405==
==5405== LEAK SUMMARY:
==5405== definitely lost: 40 bytes in 1 blocks
==5405== indirectly lost: 10,240 bytes in 10 blocks
==5405== possibly lost: 0 bytes in 0 blocks
==5405== still reachable: 0 bytes in 0 blocks
==5405== suppressed: 0 bytes in 0 blocks
...