Programowanie w systemie UNIX/Valgrind: Różnice pomiędzy wersjami

Usunięta treść Dodana treść
Nie podano opisu zmian
Linia 1:
'''Valgrind''' jest narzędziem do debugowania pamięci, wykrywania wycieków pamięci oraz profilowania aplikacji.<ref>[[w:Valgrind|Valgrind w wikipedii]]</ref><ref>[http://www.mateuszmidor.com/2011/05/debugowanie-bledow-pamieci-pod-linuxem-valgrind-memcheck/ Debugowanie błędów pamięci pod Linuxem. Valgrind + memcheck by mateusz midor ]</ref>
 
 
=Kompilacja programu=
* kompilacja z opcją <code>-g</code><ref>[httphttps://webwww.cs.swarthmore.edu/~newhall/unixhelp/purify.html Using valgrind by Tia Newhall]</ref> i <code>-O0 </code><ref name=":0">[http://valgrind.org/docs/manual/quick-start.html The Valgrind Quick Start Guide]</ref>
* uruchomienie valgrinda z opcją <code>-v</code>
 
 
gcc c.c -g
valgrind -v ./a.out
 
Możemy zapisać wynik Valgrinda do pliku, w celu łatwiejszej analizy :
 
valgrind -v ./a.out >& out # re-direct valgrind (and a.out) output to file 'out'
 
=Przykłady =
Przykład użycia :<ref>[http://www.thegeekstuff.com/2011/11/valgrind-memcheck/ How to Detect Memory Leaks Using Valgrind memcheck Tool for C / C++ by Himanshu Arora on November 28, 2011 ]</ref><ref>[http://www.cprogramming.com/debugging/valgrind.html Using Valgrind to Find Memory Leaks and Invalid Memory Use By Alex Allain]</ref>
 
valgrind --tool=memcheck ./a.out
 
albo<ref name=":0" />
 
albo <ref>[http://valgrind.org/docs/manual/quick-start.html The Valgrind Quick Start Guide]</ref>
 
valgrind --leak-check=yes ./a.out
 
lub :<ref>[http://www.geeksforgeeks.org/how-to-deallocate-memory-without-using-free-in-c/ How to deallocate memory without using free() in C? by Narendra Kangralkar]</ref>
 
valgrind --leak-check=full ./a.out
Linia 30 ⟶ 26:
=Odnośniki =
<references/>
 
 
=Zobacz również=
* [[B:en:Linux Applications Debugging Techniques| Odpluskwianie w ang wikibooks ]]
* [http://wubingzheng.github.io/memleax/ memleax : How can I find a memory leak of a running process?]