44
44
also�perform�detailed�profiling,�to�speed�up�and�reduce�memory�use�of�your<br>
47
The�Valgrind�distribution�currently�includes�five�tools:�two�memory�error<br>
48
detectors,�a�thread�error�detector,�a�cache�profiler�and�a�heap�profiler.<br>
47
The�Valgrind�distribution�currently�includes�four�tools:�a�memory�error<br>
48
detector,�a�thread�error�detector,�a�cache�profiler�and�a�heap�profiler.<br>
50
50
To�give�you�an�idea�of�what�Valgrind�tools�do,�when�a�program�is�run<br>
51
under�the�supervision�of�the�first�memory�error�detector�tool,�all�reads<br>
52
and�writes�of�memory�are�checked,�and�calls�to�malloc/new/free/delete<br>
53
are�intercepted.�As�a�result,�it�can�detect�problems�such�as:<br>
55
���Use�of�uninitialised�memory<br>
56
���Reading/writing�memory�after�it�has�been�free'd<br>
57
���Reading/writing�off�the�end�of�malloc'd�blocks<br>
58
���Reading/writing�inappropriate�areas�on�the�stack<br>
59
���Memory�leaks�--�where�pointers�to�malloc'd�blocks�are�lost�forever<br>
60
���Passing�of�uninitialised�and/or�unaddressible�memory�to�system�calls<br>
61
���Mismatched�use�of�malloc/new/new�[]�vs�free/delete/delete�[]<br>
62
���Overlaps�of�arguments�to�strcpy()�and�related�functions<br>
63
���Some�abuses�of�the�POSIX�pthread�API<br>
51
under�the�supervision�of�Memcheck,�the�memory�error�detector�tool,�all<br>
52
reads�and�writes�of�memory�are�checked,�and�calls�to�malloc/new/free/delete<br>
53
are�intercepted.��As�a�result,�Memcheck�can�detect�if�your�program:<br>
55
���-�Accesses�memory�it�shouldn't�(areas�not�yet�allocated,�areas�that�have<br>
56
�����been�freed,�areas�past�the�end�of�heap�blocks,�inaccessible�areas�of<br>
59
���-�Uses�uninitialised�values�in�dangerous�ways.<br>
61
���-�Leaks�memory.<br>
63
���-�Does�bad�frees�of�heap�blocks�(double�frees,�mismatched�frees).<br>
65
���-�Passes�overlapping�source�and�destination�memory�blocks�to�memcpy()�and<br>
66
�����related�functions.<br>
65
68
Problems�like�these�can�be�difficult�to�find�by�other�means,�often<br>
66
69
lying�undetected�for�long�periods,�then�causing�occasional,<br>