개발정보/안드로이드
안드로이드 개발 레벨업 교과서 14장 최적화
dev김
2019. 1. 17. 17:05
Rail 퍼포먼스 모델
https://developers.google.com/web/fundamentals/performance/rail
(웹의 Idle 제외)
onCreate에서 StrictMode 사용
프로파일러 간이 스스로 System.nanoTime()
Traceview 안드로이드 모니터 cpu탭 스톱워치 클릭으로 기록
Systrace 4.3이상(4.1) 플랫폼툴즈systrace
lint 레이아웃 최적화 lint --show 검사항목 리스트
개발자 옵션 오버드로 활성화
hierarchyviewer 에뮬레이터나 루팅단말이나 viewserver 도입
안드로이드 모니터 메모리 감시
LeakCanary를 이용해 메모리 누수 방지 릴리즈와 테스트는 동작안함
application onCreate에서 LeakCanary.install(this);
HashMap 대신 ArrayMap SimpleArrayMap 사용해 메모리 최적화
오토박싱(int->Integer)을 피하기 위해
HashMap 대신 SparseArrayCompat사용 LongSparseArray도 존재
https://developers.google.com/web/fundamentals/performance/rail
(웹의 Idle 제외)
onCreate에서 StrictMode 사용
if(DEVELOP_MODE) //개발모드에서만 동작하도록 { StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() .detectDiskReads().detectDiskWrites().detectNetwork().penaltyLog().build()); }병목현상 StrictMode로 확인 정책위반시 penaltyLog() penaltyDeath()
프로파일러 간이 스스로 System.nanoTime()
Traceview 안드로이드 모니터 cpu탭 스톱워치 클릭으로 기록
Systrace 4.3이상(4.1) 플랫폼툴즈systrace
$cd android-sdk/platform-tools/systrace $python systrace.py —time=10 -o /tmp/mynewtrace.html sched gfx view wm --app com.github.advanced_android.newgithubreposystrace도움말 https://developer.android.com/studio/command-line/systrace
lint 레이아웃 최적화 lint --show 검사항목 리스트
레이아웃 오른쪽 클릭->Inspect Code실행
개발자 옵션 오버드로 활성화
hierarchyviewer 에뮬레이터나 루팅단말이나 viewserver 도입
https://github.com/romainguy/viewserver
안드로이드 모니터 메모리 감시
LeakCanary를 이용해 메모리 누수 방지 릴리즈와 테스트는 동작안함
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.3.1' releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1' testImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'releaseCompile '~~.leakcanary-android-no-op:1.3.1'(no op아무것도 하지않음)
application onCreate에서 LeakCanary.install(this);
fragment는 RefWatcher 사용 refWatcher = LeakCanary.install(this);
application.refWatcher;
application.refWatcher;
HashMap 대신 ArrayMap SimpleArrayMap 사용해 메모리 최적화
오토박싱(int->Integer)을 피하기 위해
HashMap