Android performance tuning. Memory.
-
Upload
sergii-kozyrev -
Category
Engineering
-
view
156 -
download
5
Transcript of Android performance tuning. Memory.
ANDROID PERFORMANCE TUNING MEMORY
SERGII KOZYREVSeniorSE
22.06.2016
Memory
Garbage Collector is such a cool feature
There is always taxes -“performance is not free”? :)
Understanding memory
•GC•Findobjectsthatcan’tbeaccessed•Reclaimtheresources
•Questions:•HeapvsStackmemory?•WhatGCcollects?•Howleakshappens?
Concerns
Memory Leaks
•It’snotonlyaboutOutOfMemoryError
•ItreducesavailablememoryandcausesGCrunmorefrequent- whichisbad
Different VMs – different Logs
•Dalvik (everyGC)•ART(iftheGCpauseexceedsthan5msortheGCdurationexceeds100ms)
Concurrent VSAlloc
DEMO Memory Monitor
Memory Leaks
•Simple- “handlercase”,oreverycircularreferencedobjects
•Complex- holdingahandletotheClassLoader objects,loadinonCreate anddon’tcheckifclassesalreadyloaded(noclassunloadprocedure)
Memory Leaks•StaticActivities,Views,Contextawarestuff
• InnerClasses
•AnonymousClasses
•Handlers
•ThreadsandTimerTask
•SensorManager
DEMO HeapViewver
Move allocations out of inner loops :)
DEMO Allocation Tracker
Thank You!
Links:https://github.com/kozyrevsergey89/PerformanceLab
https://github.com/square/leakcanaryhttps://www.udacity.com/course/android-performance--ud825