Valgrind: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 1: Line 1:
 
<languages />
<translate>
=Valgrind=
=Valgrind=


Line 24: Line 25:
==== Memory leak ====
==== Memory leak ====
The error message for a memory leak will be given at the end of the program execution, and will look like this :  
The error message for a memory leak will be given at the end of the program execution, and will look like this :  
</translate>
<syntaxhighlight lang=text>
<syntaxhighlight lang=text>
==2116== 100 bytes in 1 blocks are definitely lost in loss record 1 of 1
==2116== 100 bytes in 1 blocks are definitely lost in loss record 1 of 1
Line 29: Line 31:
==2116==    by 0x804840F: main (in /home/cprogram/example1)
==2116==    by 0x804840F: main (in /home/cprogram/example1)
</syntaxhighlight>
</syntaxhighlight>
 
<translate>
==== Invalid pointer access/out of bound errors ====
==== Invalid pointer access/out of bound errors ====
If you attempt to read or write to an unallocated pointer or outside of the allocated memory, the error message will look like this:
If you attempt to read or write to an unallocated pointer or outside of the allocated memory, the error message will look like this:
</translate>
<syntaxhighlight lang=text>
<syntaxhighlight lang=text>
==9814==  Invalid write of size 1
==9814==  Invalid write of size 1
Line 39: Line 42:
==9814==    by 0x804840F: main (example2.c:5)
==9814==    by 0x804840F: main (example2.c:5)
</syntaxhighlight>
</syntaxhighlight>
 
<translate>
==== Usage of uninitialized variables ====
==== Usage of uninitialized variables ====
If you use an uninitialized variable, you will get an error message such as
If you use an uninitialized variable, you will get an error message such as
</translate>
<syntaxhighlight lang=text>
<syntaxhighlight lang=text>
==17943== Conditional jump or move depends on uninitialised value(s)
==17943== Conditional jump or move depends on uninitialised value(s)
==17943==    at 0x804840A: main (example3.c:6)
==17943==    at 0x804840A: main (example3.c:6)
</syntaxhighlight>
</syntaxhighlight>
Bureaucrats, cc_docs_admin, cc_staff
2,318

edits