코어 파일 분석에서 메모리 누수를 분석하고 싶습니다.코어 덤프에서 메모리 누수를 분석하는 방법
메모리 누수를 주입하고 gcore 명령으로 코어 파일을 생성하는 샘플 코드를 작성했습니다.
#include <stdlib.h>
#include <unistd.h>
void fun()
{
int *ptr = new int(1234);
}
int main()
{
int i=0;
while(i++<2500)
{
fun();
}
sleep(360);
return 0;
}
프로세스 ID
[email protected]:~$ ps -aef |grep over
ajay 8735 6016 0 12:57 pts/2 00:00:00 ./over
ayadav 8739 4659 0 12:57 pts/10 00:00:00 grep over
생성 된 코어를 찾기
[email protected]:~$ sudo gcore 8735
[sudo] password for ayadav:
0x00007fbb7dda99a0 in __nanosleep_nocancel() at ../sysdeps/unix/syscall-template.S:81
81 ../sysdeps/unix/syscall-template.S: No such file or directory.
Saved corefile core.8735
나는 다음과 같이 코어 파일에서 일반적인 패턴을 발견했다 (에 제안을 유래 다른 스레드 Is there a way to locate which part of the process used the most of the memory, only looking at a generated core file?)
[email protected]:~$ hexdump core.6015 | awk '{printf "%s%s%s%s\n%s%s%s%s\n", $5,$4,$3,$2,$9,$8,$7,$6}' | sort | uniq -c | sort -nr | head
6913 0000000000000000
2503 0000002100000000
2501 000004d200000000
786 0000000000007ffc
464
125 1ccbc4d000007ffc
92 1ca7ead000000000
91 0000000200007ffc
89 0000000100007ffc
80 0000000100000000
이 아래 주소는 반복 패턴
0003560 0000 0000 0021 0000 0000 0000 04d2 0000
0003570 0000 0000 0000 0000 0000 0000 0000 0000
0003580 0000 0000 0021 0000 0000 0000 04d2 0000
0003590 0000 0000 0000 0000 0000 0000 0000 0000
00035a0 0000 0000 0021 0000 0000 0000 04d2 0000
00035b0 0000 0000 0000 0000 0000 0000 0000 0000
00035c0 0000 0000 0021 0000 0000 0000 04d2 0000
00035d0 0000 0000 0000 0000 0000 0000 0000 0000
00035e0 0000 0000 0021 0000 0000 0000 04d2 0000
00035f0 0000 0000 0000 0000 0000 0000 0000 0000
0003600 0000 0000 0021 0000 0000 0000 04d2 0000
0003610 0000 0000 0000 0000 0000 0000 0000 0000
0003620 0000 0000 0021 0000 0000 0000 04d2 0000
0003630 0000 0000 0000 0000 0000 0000 0000 0000
0003640 0000 0000 0021 0000 0000 0000 04d2 0000
다음 하나 개
2503 0000002100000000
2501 000004d200000000
코어 파일을 한 것으로 의심되는하지만 내가 GDB 정보 주소 또는 X 같은 명령에서 액세스 할 수 있습니다 얼마나 많은 생각이 없습니다. 아무도 내가 이진 형식에서 기호 정보를 어떻게 변환 할 수 있는지 말할 수 있습니까?
[코어 덤프 파일 분석] (http://stackoverflow.com/questions/5115613/core-dump-file-analysis) – gj13
가능한 중복 [프로그램의 코어 덤프 파일을 분석하는 방법은?] (http://stackoverflow.com/questions/8305866/how-to-analyze-a-programs-core-dump-file) – skaffman
중복되지 않습니다 –