Bonjour,

J'ai envie de vérifier si un de mes programme comporte des fuites mémoire. J'ai donc installé valgrind (3.0.1), pour tester cela. Avant de tester mon programme, je comptais "tester" valgrind, en créant un petit programme contenant une belle fuite mémoire, histoire de voir ce qu'il allait me donner. Le voici :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
using namespace std;
 
int main (int argc, char* argv[])
{
	int *x = new int[10];
	x[1]=5;
	return 0;
}

N'ayant pas désalloué mon pointeur, je pensais avoir créé ma fuite. Mais voici ce que me rapporte valgrind :

==16761== Memcheck, a memory error detector.
==16761== Copyright (C) 2002-2005, and GNU GPL'd, by Julian Seward et al.
==16761== Using LibVEX rev 1367, a library for dynamic binary translation.
==16761== Copyright (C) 2004-2005, and GNU GPL'd, by OpenWorks LLP.
==16761== Using valgrind-3.0.1, a dynamic binary instrumentation framework.
==16761== Copyright (C) 2000-2005, and GNU GPL'd, by Julian Seward et al.
==16761== For more details, rerun with: -v
==16761==
==16761== Conditional jump or move depends on uninitialised value(s)
==16761== at 0x119106B1: (within /lib/ld-2.3.5.so)
==16761== by 0x11904454: (within /lib/ld-2.3.5.so)
==16761== by 0x11904A9C: (within /lib/ld-2.3.5.so)
==16761== by 0x11902360: (within /lib/ld-2.3.5.so)
==16761== by 0x1190EB6F: (within /lib/ld-2.3.5.so)
==16761== by 0x119014ED: (within /lib/ld-2.3.5.so)
==16761== by 0x11900A37: (within /lib/ld-2.3.5.so)
(autres erreurs comme celle-ci, venant de libc)
==16761==
==16761== ERROR SUMMARY: 8 errors from 8 contexts (suppressed: 0 from 0)
==16761== malloc/free: in use at exit: 0 bytes in 0 blocks.
==16761== malloc/free: 30 allocs, 30 frees, 3681 bytes allocated.
==16761== For counts of detected errors, rerun with: -v
==16761== No malloc'd blocks -- no leaks are possible.
Visiblement, il trouve qu'il n'y a pas de fuite mémoire... Est-ce vrai?