갈라파고스
[Linux] Valgrind 설치 및 사용법 본문
원인
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"
참고
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
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
'연구 > Linux' 카테고리의 다른 글
[Linux] SGE(Son of Grid Engine) 설치 및 사용법 (0) | 2022.10.26 |
---|---|
[Linux] Warning: No xauth data; using fake authentication data for X11 forwarding. (0) | 2022.08.23 |
[Linux] vi로 파일 비교하고 수정하기 (0) | 2022.06.28 |
[Linux] qsub 하면 ModuleNotFoundError: No module named 'numpy' (0) | 2022.06.23 |
[Linux] 이름 깨진 파일 삭제 (0) | 2022.06.21 |