Study/App
[Android] adb를 이용한 메모리 덤프
Notchicken
2019. 11. 21. 14:46
※ adb dumpheap을 이용하여 메모리 덤프를 하기 위해서는 해당 앱의 AndroidManifest.xml 파일에
android:debuggable="true" 가 설정되어 있어야 한다.
1. adb shell 접속
cmd >> adb shell
adb >> su
2. 메모리 덤프를 위한 프로세스 id 확인
adb >> ps | grep "앱이름"
zeroflteskt:/ # ps | grep abcd
u0_a303 13549 4657 2613888 52344 SyS_epoll_ 788027d5f4 S com.xxx.abcd:remote
u0_a303 29429 4657 4191380 359560 SyS_epoll_ 788027d5f4 S com.xxx.xxxx.abcd
3. dumpheap을 이용한 메모리 덤프
adb >> am dumpheap 29429 /data/local/tmp/test.hprof
adb >> cd /data/local/tmp
adb >> chmod 777 test.hprof
adb >> strings test.hprof > test.txt
4. 덤프파일 pc로 가져오기
cmd >> adb pull /data/local/tmp/test.txt C:\Users\test\Desktop