Recent Posts
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Today
Total
관리 메뉴

갈라파고스

[Linux] Valgrind 설치 및 사용법 본문

연구/Linux

[Linux] Valgrind 설치 및 사용법

9yelin9 2022. 9. 26. 12:02

원인

c로 코드를 짜다 보면 무조건 메모리 문제가 발생한다. 무조건!!!

이번 미팅때 교수님께서 메모리 누수를 검사해주는 툴을 알려주셔서 한번 사용해보려고 한다.

 

해결

1. 설치

다음을 순서대로 입력하여 설치한다.

git clone https://sourceware.org/git/valgrind.git
cd valgrind
./autogen.sh
./configure --prefix=$HOME/.local/valgrind
make
make install

 

2. 사용

valgrind --leak-check=full --log-file=memcheck.txt --error-limit=no -v [프로그램 경로] [인자]

 

옵션 설명

--leak-check=full : 모든 에러를 출력한다.

--log-file=memcheck.txt : memcheck.txt 파일에 로그를 출력한다.

--error-limit=no : 에러 출력 제한을 없앤다.

--show-reachable=yes : --show-leak-kinds=all 과 같은 기능 / 불분명한 에러들까지 모두 출력한다.

-v : 자세한 내용을 출력한다.

 

3. valgrind: failed to start tool 'memcheck' for platform 'amd64-linux': No such file or directory

이런 에러 메세지가 뜨면 .bashrc에 다음을 추가한다.

export VALGRIND_LIB="$HOME/.local/valgrind/libexec/valgrind"

 

참고

https://valgrind.org/

 

Valgrind Home

Valgrind is an instrumentation framework for building dynamic analysis tools. There are Valgrind tools that can automatically detect many memory management and threading bugs, and profile your programs in detail. You can also use Valgrind to build new tool

valgrind.org

https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=fromyongsik&logNo=40167969693 

 

[펌]valgrind, 발그린드 사용법

출처 - http://stormaa.tistory.com/5 리눅스에서 프로그램을 만들다 보면 Memo...

blog.naver.com

https://stackoverflow.com/questions/3239343/make-install-but-not-to-default-directories

 

Make install, but not to default directories?

I want to run 'make install' so I have everything I need, but I'd like it to install the things in their own folder as opposed to the system's /usr/bin etc. is that possible? even if it references ...

stackoverflow.com

https://stackoverflow.com/questions/64813183/ubuntu-valgrind-failed-to-start-tool-memcheck-for-platform-amd64-linux-no

 

Ubuntu: valgrind: failed to start tool 'memcheck' for platform 'amd64-linux': No such file or directory

I have installed valgrind with no problems but when running it I keep getting the following error: valgrind: failed to start tool 'memcheck' for platform 'amd64-linux': No such file or directory I...

stackoverflow.com

Comments