16
ANDROID PERFORMANCE TUNING MEMORY SERGII KOZYREV Senior SE 22.06.2016

Android performance tuning. Memory

Embed Size (px)

Citation preview

Page 1: Android performance tuning. Memory

ANDROID PERFORMANCE TUNING MEMORY

SERGII KOZYREVSeniorSE

22.06.2016

Page 2: Android performance tuning. Memory

Memory

Page 3: Android performance tuning. Memory

Garbage Collector is such a cool feature

Page 4: Android performance tuning. Memory

There is always taxes -“performance is not free”? :)

Page 5: Android performance tuning. Memory

Understanding memory

•GC•Findobjectsthatcan’tbeaccessed•Reclaimtheresources

•Questions:•HeapvsStackmemory?•WhatGCcollects?•Howleakshappens?

Page 6: Android performance tuning. Memory

Concerns

Page 7: Android performance tuning. Memory

Memory Leaks

•It’snotonlyaboutOutOfMemoryError

•ItreducesavailablememoryandcausesGCrunmorefrequent- whichisbad

Page 8: Android performance tuning. Memory

Different VMs – different Logs

•Dalvik (everyGC)•ART(iftheGCpauseexceedsthan5msortheGCdurationexceeds100ms)

Concurrent VSAlloc

Page 9: Android performance tuning. Memory

DEMO Memory Monitor

Page 10: Android performance tuning. Memory

Memory Leaks

•Simple- “handlercase”,oreverycircularreferencedobjects

•Complex- holdingahandletotheClassLoader objects,loadinonCreate anddon’tcheckifclassesalreadyloaded(noclassunloadprocedure)

Page 11: Android performance tuning. Memory

Memory Leaks•StaticActivities,Views,Contextawarestuff

• InnerClasses

•AnonymousClasses

•Handlers

•ThreadsandTimerTask

•SensorManager

Page 12: Android performance tuning. Memory

DEMO HeapViewver

Page 13: Android performance tuning. Memory

Move allocations out of inner loops :)

Page 14: Android performance tuning. Memory

DEMO Allocation Tracker

Page 15: Android performance tuning. Memory

Thank You!

Page 16: Android performance tuning. Memory

Links:https://github.com/kozyrevsergey89/PerformanceLab

https://github.com/square/leakcanaryhttps://www.udacity.com/course/android-performance--ud825