SlideShare a Scribd company logo
Avoiding memory
leaks in Android
Denis Zhuchinski
Prom.ua
d.zhuchinskiy@smartweb.com.ua
https://github.com/zhuchinskyi/
https://ua.linkedin.com/in/denys-zhuchinskyi-96ab0673
Agenda
● Memory Management
● Garbage Collector
● Memory Leaks
● Tools
● Demo
● How to avoid OutOfMemoryError?
Memory Management
Android Memory Management
● Each app process is forked from an existing process
called Zygote
● No swap space
● Virtual Address Space (Memory management unit)
● Paging and Memory-Mapping (mmapping)
● Process space limitation
Sharing Memory
● Binder IPC Driver
● Android shares the same dynamic RAM across
processes using explicitly allocated shared memory
regions (ashmem)
● Most static data is mmapped into a process (VM code,
app resources, native code)
Application Memory Restrictions
● Isolated in process
● Hard limit heap size
● Heap size limit varies between devices
● Low-Memory Killer (Proportional Set Size)
ActivityManager.getMemoryClass()
ActivityManager.getLargeMemoryClass()
Process Priority
Activity Process
Visible Process
Service Process
Background
Process
Empty Process
Critical Priority
High Priority
Low Priority
Main Process Memory Areas
● Stack (local variables, partial results, method invocation)
● Heap (all objects)
○ Java
○ Native
● java.lang.StackOverFlow
● java.lang.OutOfMemoryError
Main Process Memory Areas
● Stack (local variables, partial results, method invocation)
● Heap (all objects)
○ Java
○ Native
● java.lang.StackOverFlow
● java.lang.OutOfMemoryError
Garbage Collection
Garbage Collection
● Automatic memory management scheme
● VM performs routine garbage collection (GC)
● Uses mark-and-sweep algorithm
Dalvik and ART
ART GC Enhancement
● Enumerates all allocated objects and marks all reachable objects in
only one pause while Dalvik’s GC pauses twice
○ enumeration phase performed by application
○ pre-cleaning technique
● Parallelization
● Lower total GC time (cleaning up recently-allocated)
● Compacting GC merges freed-up single blocks in one location of
memory
(Still in development by Android Open-Source Project)
ART GC Enhancement
Memory Leaks
● Memory leak: situation where some objects are not used by
application any more, but GC fails to recognize them as unused
● Memory consumption increases -> Degradation in performance
● GC does not prevent leaks!
Memory Leaks
How to detect?
● Huge memory consumption in Android Studio Memory Monitor
● Frequent GC calls in LogCat
● App crashes with an OutOfMemmoryError (OOM)
D/dalvikvm: <GC_Reason> <Amount_freed>, <Heap_stats>, <External_memory_stats>, <Pause_time>
07-02 15:56:14.275: D/dalvikvm(30615): GC_FOR_ALLOC freed 4442K, 25% free 20183K/26856K, paused 24ms, total 24ms
07-02 15:56:16.785: I/dalvikvm-heap(30615): Grow heap (frag case) to 38.179MB for 8294416-byte allocation
07-02 15:56:17.225: I/dalvikvm-heap(30615): Grow heap (frag case) to 48.279MB for 7361296-byte allocation
07-02 15:56:17.625: I/Choreographer(30615): Skipped 35 frames! The application may be doing too much work on its main thread.
07-02 15:56:19.035: D/dalvikvm(30615): GC_CONCURRENT freed 35838K, 43% free 51351K/89052K, paused 3ms+5ms, total 106ms
I/art: <GC_Reason> <GC_Name> <Objects_freed>(<Size_freed>) AllocSpace Objects, Large_objects_freed>
(<Large_object_size_freed>) <Heap_stats> LOS objects, <Pause_time(s)>
07-02 16:00:44.531: I/art(198): Explicit concurrent mark sweep GC freed 700(30KB) AllocSpace objects, 0(0B) LOS objects, 792% free,
18MB/21MB, paused 186us total 12.763ms
07-02 16:00:44.545: I/art(198): Explicit concurrent mark sweep GC freed 7(240B) AllocSpace objects, 0(0B) LOS objects, 792% free,
18MB/21MB, paused 198us total 9.465ms
07-02 16:00:44.554: I/art(198): Explicit concurrent mark sweep GC freed 5(160B) AllocSpace objects, 0(0B) LOS objects, 792% free,
18MB/21MB, paused 224us total 9.045ms
Dalvik GC Reason
● GC_CONCURRENT
● GC_FOR_MALLOC
● GC_HPROF_DUMP_HEAP
● GC_EXPLICIT
● GC_EXTERNAL_ALLOC
D/dalvikvm: <GC_Reason> <Amount_freed>, <Heap_stats>,
<External_memory_stats>, <Pause_time>
ART GC Reason
● Concurrent
● Alloc
● Explicit
● NativeAlloc
● CollectorTransition
● HomogeneousSpaceCompact
I/art: <GC_Reason> <GC_Name> <Objects_freed>(<Size_freed>) AllocSpace
Objects, Large_objects_freed> (<Large_object_size_freed>) <Heap_stats>
LOS objects, <Pause_time(s)>
Tools
Tools
● adb shell dumpsys meminfo <package_name | pid>
● Android Monitor
○ Heap Dump
○ Allocation Tracker
● Eclipse Memory Analyzer Tool (MAT)
● LeakCanary (Square)
Demo
https://github.com/zhuchinskyi/MemoryLeakSample.git
● Do not keep long-lived references to an Activity, Context, View, Drawable...
● Avoid non-static inner classes in an activity if you don’t control their life cycle
● Avoid mutable static fields
● Use Weak References
● Try to not have long living objects
● Use as much as possible application Context instead of Activity
● Remember to call unregisterReceiver() after calling registerReceiver()
● Implement cancellation policies for background threads
● Use LeakCanary in the QA cycle
● Keep an eye on the heap while the app is running
● Don’t assume GC will clean up all for you!
● Search for memory leaks even when things aren't failing!
How to avoid Memory Leaks?
● Use bitmaps with correct resolution
● Recycle the bitmaps more often, instead of just onDestroy()
● Send large files to server by chunks
● Avoid creating unnecessary objects
● Check the available heap of your application
● Coordinate with the system by implementing onTrimMemory() callback
● External libraries should be used carefully
● Use Proguard and zipalign
How to avoid OutofMemoryError?
References
● http://developer.android.com/intl/ru/training/articles/memory.html
● https://xakep.ru/2014/05/21/excurse-in-android-architecture/
● https://software.intel.com/en-us/android/articles/art-vs-dalvik-introducing-the-new-android-
x86-runtime
● https://software.intel.com/en-us/android/articles/tips-for-optimizing-android-application-
memory-usage
● https://android.googlesource.com/platform/art/+/master/runtime/gc/
● http://developer.android.com/intl/ru/tools/debugging/debugging-memory.html
● http://www.raizlabs.com/dev/2014/03/wrangling-dalvik-memory-management-in-android-part-
1-of-2/
● https://acadgild.com/blog/analyze-manage-android-devices-memory-allocation-through-ddms-
mat/
● http://developer.android.com/intl/ru/tools/help/am-memory.html
● http://developer.android.com/tools/debugging/debugging-memory.html
Q&A

More Related Content

PDF
Xamarin.android memory management gotchas
ODP
Orm android
PPT
Introduction to Android Environment
PDF
Павел Тайкало: "Apple watch first steps"
PDF
Анна Лаврова "When Fairy Tale meets Reality: Точность-надежность-дизайн"
PPT
"От разработчика в консультанты - история одного тренера" Александр Баглай
PDF
"Fun with JavaScript and sensors" by Jan Jongboom
PDF
"The Grail: React based Isomorph apps framework" Эльдар Джафаров
Xamarin.android memory management gotchas
Orm android
Introduction to Android Environment
Павел Тайкало: "Apple watch first steps"
Анна Лаврова "When Fairy Tale meets Reality: Точность-надежность-дизайн"
"От разработчика в консультанты - история одного тренера" Александр Баглай
"Fun with JavaScript and sensors" by Jan Jongboom
"The Grail: React based Isomorph apps framework" Эльдар Джафаров

Viewers also liked (20)

PDF
"Посмотрим на Акку-Джаву" Дмитрий Мантула
PDF
Андрей Уманский и Дмитрий Горин "Нет скучным ретроспективам! Создаём эффектив...
PDF
Максим Климишин "Борьба с асинхронностью в JS"
PPTX
"Walk in a distributed systems park with Orleans" Евгений Бобров
PDF
Ruby w/o Rails (Олександр Сімонов)
PDF
Александр Корниенко "Как реально построить Dream-team?"
PDF
Алексей Демедецкий | Unit testing in swift
PDF
"Хероковая жизнь" Юрий Литвиненко
PDF
"Backbone React Flux" Артем Тритяк
PDF
"From CRUD to Hypermedia APIs with Spring" Владимир Цукур
PDF
"Выучить язык программирования за 25 минут" Дмитрий Мантула
PPTX
Маргарита Остапчук "Що нового в Windows 10 для розробників"
PPTX
Михаил Чалый "Serverless Architectures using .NET and Azure"
PPTX
"Эффективность и оптимизация кода в Java 8" Сергей Моренец
PPTX
Сергей Больщиков "Angular Components: все уже за, а вы еще нет?"
PPTX
"Война типов: сильные против слабых" Виктор Полищук
PDF
Николай Паламарчук "Управление зависимостями в больших проектах"
PDF
Антон Бойко "Azure Web Apps deep dive"
PDF
"Reducers in Action" Антон Молдован
PDF
Роман Сахаров "Stakeholders and expectations, или когда проекты успешны?"
"Посмотрим на Акку-Джаву" Дмитрий Мантула
Андрей Уманский и Дмитрий Горин "Нет скучным ретроспективам! Создаём эффектив...
Максим Климишин "Борьба с асинхронностью в JS"
"Walk in a distributed systems park with Orleans" Евгений Бобров
Ruby w/o Rails (Олександр Сімонов)
Александр Корниенко "Как реально построить Dream-team?"
Алексей Демедецкий | Unit testing in swift
"Хероковая жизнь" Юрий Литвиненко
"Backbone React Flux" Артем Тритяк
"From CRUD to Hypermedia APIs with Spring" Владимир Цукур
"Выучить язык программирования за 25 минут" Дмитрий Мантула
Маргарита Остапчук "Що нового в Windows 10 для розробників"
Михаил Чалый "Serverless Architectures using .NET and Azure"
"Эффективность и оптимизация кода в Java 8" Сергей Моренец
Сергей Больщиков "Angular Components: все уже за, а вы еще нет?"
"Война типов: сильные против слабых" Виктор Полищук
Николай Паламарчук "Управление зависимостями в больших проектах"
Антон Бойко "Azure Web Apps deep dive"
"Reducers in Action" Антон Молдован
Роман Сахаров "Stakeholders and expectations, или когда проекты успешны?"
Ad

Similar to "Avoiding memory leaks in Android" Денис Жучинский (20)

PDF
Effective memory management
PDF
Effective memory management
PDF
Elastic JVM for Scalable Java EE Applications Running in Containers #Jakart...
PDF
Android Memory , Where is all My RAM
PPTX
this-is-garbage-talk-2022.pptx
PDF
Choosing Right Garbage Collector to Increase Efficiency of Java Memory Usage
ODP
Memory management
PPTX
millions-gc-jax-2022.pptx
PDF
JVM Performance Tuning
PDF
Garelic: Google Analytics as App Performance monitoring
PPTX
Android Performance and Profiling Tips
PDF
AndroidMemoryProfiling
PDF
Android Platform Debugging and Development
PDF
Android Platform Debugging and Development
PPTX
What’s new in aNdroid [Google I/O Extended Bangkok 2016]
PDF
Android Platform Debugging and Development
PDF
Android Platform Debugging and Development
PDF
performance optimization: Memory
PDF
Detecting Memory Leaks in Android A/B Tests: A Production-Focused Approach by...
PDF
Android Platform Debugging and Development
Effective memory management
Effective memory management
Elastic JVM for Scalable Java EE Applications Running in Containers #Jakart...
Android Memory , Where is all My RAM
this-is-garbage-talk-2022.pptx
Choosing Right Garbage Collector to Increase Efficiency of Java Memory Usage
Memory management
millions-gc-jax-2022.pptx
JVM Performance Tuning
Garelic: Google Analytics as App Performance monitoring
Android Performance and Profiling Tips
AndroidMemoryProfiling
Android Platform Debugging and Development
Android Platform Debugging and Development
What’s new in aNdroid [Google I/O Extended Bangkok 2016]
Android Platform Debugging and Development
Android Platform Debugging and Development
performance optimization: Memory
Detecting Memory Leaks in Android A/B Tests: A Production-Focused Approach by...
Android Platform Debugging and Development
Ad

More from Fwdays (20)

PDF
"Mastering UI Complexity: State Machines and Reactive Patterns at Grammarly",...
PDF
"Effect, Fiber & Schema: tactical and technical characteristics of Effect.ts"...
PPTX
"Computer Use Agents: From SFT to Classic RL", Maksym Shamrai
PPTX
"Як ми переписали Сільпо на Angular", Євген Русаков
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
PDF
"Validation and Observability of AI Agents", Oleksandr Denisyuk
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
PPTX
"Co-Authoring with a Machine: What I Learned from Writing a Book on Generativ...
PPTX
"Human-AI Collaboration Models for Better Decisions, Faster Workflows, and Cr...
PDF
"AI is already here. What will happen to your team (and your role) tomorrow?"...
PPTX
"Is it worth investing in AI in 2025?", Alexander Sharko
PDF
''Taming Explosive Growth: Building Resilience in a Hyper-Scaled Financial Pl...
PDF
"Scaling in space and time with Temporal", Andriy Lupa.pdf
PDF
"Database isolation: how we deal with hundreds of direct connections to the d...
PDF
"Scaling in space and time with Temporal", Andriy Lupa .pdf
PPTX
"Provisioning via DOT-Chain: from catering to drone marketplaces", Volodymyr ...
PPTX
" Observability with Elasticsearch: Best Practices for High-Load Platform", A...
PPTX
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
PPTX
"Istio Ambient Mesh in production: our way from Sidecar to Sidecar-less",Hlib...
"Mastering UI Complexity: State Machines and Reactive Patterns at Grammarly",...
"Effect, Fiber & Schema: tactical and technical characteristics of Effect.ts"...
"Computer Use Agents: From SFT to Classic RL", Maksym Shamrai
"Як ми переписали Сільпо на Angular", Євген Русаков
"AI Transformation: Directions and Challenges", Pavlo Shaternik
"Validation and Observability of AI Agents", Oleksandr Denisyuk
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
"Co-Authoring with a Machine: What I Learned from Writing a Book on Generativ...
"Human-AI Collaboration Models for Better Decisions, Faster Workflows, and Cr...
"AI is already here. What will happen to your team (and your role) tomorrow?"...
"Is it worth investing in AI in 2025?", Alexander Sharko
''Taming Explosive Growth: Building Resilience in a Hyper-Scaled Financial Pl...
"Scaling in space and time with Temporal", Andriy Lupa.pdf
"Database isolation: how we deal with hundreds of direct connections to the d...
"Scaling in space and time with Temporal", Andriy Lupa .pdf
"Provisioning via DOT-Chain: from catering to drone marketplaces", Volodymyr ...
" Observability with Elasticsearch: Best Practices for High-Load Platform", A...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"Istio Ambient Mesh in production: our way from Sidecar to Sidecar-less",Hlib...

Recently uploaded (20)

PDF
Encapsulation theory and applications.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
KodekX | Application Modernization Development
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Approach and Philosophy of On baking technology
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Empathic Computing: Creating Shared Understanding
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
Cloud computing and distributed systems.
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
Encapsulation theory and applications.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
KodekX | Application Modernization Development
MIND Revenue Release Quarter 2 2025 Press Release
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Approach and Philosophy of On baking technology
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Empathic Computing: Creating Shared Understanding
sap open course for s4hana steps from ECC to s4
Reach Out and Touch Someone: Haptics and Empathic Computing
Understanding_Digital_Forensics_Presentation.pptx
Programs and apps: productivity, graphics, security and other tools
The AUB Centre for AI in Media Proposal.docx
Encapsulation_ Review paper, used for researhc scholars
Digital-Transformation-Roadmap-for-Companies.pptx
Spectral efficient network and resource selection model in 5G networks
Diabetes mellitus diagnosis method based random forest with bat algorithm
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Cloud computing and distributed systems.
Dropbox Q2 2025 Financial Results & Investor Presentation

"Avoiding memory leaks in Android" Денис Жучинский

  • 1. Avoiding memory leaks in Android Denis Zhuchinski Prom.ua d.zhuchinskiy@smartweb.com.ua https://github.com/zhuchinskyi/ https://ua.linkedin.com/in/denys-zhuchinskyi-96ab0673
  • 2. Agenda ● Memory Management ● Garbage Collector ● Memory Leaks ● Tools ● Demo ● How to avoid OutOfMemoryError?
  • 4. Android Memory Management ● Each app process is forked from an existing process called Zygote ● No swap space ● Virtual Address Space (Memory management unit) ● Paging and Memory-Mapping (mmapping) ● Process space limitation
  • 5. Sharing Memory ● Binder IPC Driver ● Android shares the same dynamic RAM across processes using explicitly allocated shared memory regions (ashmem) ● Most static data is mmapped into a process (VM code, app resources, native code)
  • 6. Application Memory Restrictions ● Isolated in process ● Hard limit heap size ● Heap size limit varies between devices ● Low-Memory Killer (Proportional Set Size) ActivityManager.getMemoryClass() ActivityManager.getLargeMemoryClass()
  • 7. Process Priority Activity Process Visible Process Service Process Background Process Empty Process Critical Priority High Priority Low Priority
  • 8. Main Process Memory Areas ● Stack (local variables, partial results, method invocation) ● Heap (all objects) ○ Java ○ Native ● java.lang.StackOverFlow ● java.lang.OutOfMemoryError
  • 9. Main Process Memory Areas ● Stack (local variables, partial results, method invocation) ● Heap (all objects) ○ Java ○ Native ● java.lang.StackOverFlow ● java.lang.OutOfMemoryError
  • 11. Garbage Collection ● Automatic memory management scheme ● VM performs routine garbage collection (GC) ● Uses mark-and-sweep algorithm
  • 13. ART GC Enhancement ● Enumerates all allocated objects and marks all reachable objects in only one pause while Dalvik’s GC pauses twice ○ enumeration phase performed by application ○ pre-cleaning technique ● Parallelization ● Lower total GC time (cleaning up recently-allocated) ● Compacting GC merges freed-up single blocks in one location of memory (Still in development by Android Open-Source Project)
  • 16. ● Memory leak: situation where some objects are not used by application any more, but GC fails to recognize them as unused ● Memory consumption increases -> Degradation in performance ● GC does not prevent leaks! Memory Leaks
  • 17. How to detect? ● Huge memory consumption in Android Studio Memory Monitor ● Frequent GC calls in LogCat ● App crashes with an OutOfMemmoryError (OOM) D/dalvikvm: <GC_Reason> <Amount_freed>, <Heap_stats>, <External_memory_stats>, <Pause_time> 07-02 15:56:14.275: D/dalvikvm(30615): GC_FOR_ALLOC freed 4442K, 25% free 20183K/26856K, paused 24ms, total 24ms 07-02 15:56:16.785: I/dalvikvm-heap(30615): Grow heap (frag case) to 38.179MB for 8294416-byte allocation 07-02 15:56:17.225: I/dalvikvm-heap(30615): Grow heap (frag case) to 48.279MB for 7361296-byte allocation 07-02 15:56:17.625: I/Choreographer(30615): Skipped 35 frames! The application may be doing too much work on its main thread. 07-02 15:56:19.035: D/dalvikvm(30615): GC_CONCURRENT freed 35838K, 43% free 51351K/89052K, paused 3ms+5ms, total 106ms I/art: <GC_Reason> <GC_Name> <Objects_freed>(<Size_freed>) AllocSpace Objects, Large_objects_freed> (<Large_object_size_freed>) <Heap_stats> LOS objects, <Pause_time(s)> 07-02 16:00:44.531: I/art(198): Explicit concurrent mark sweep GC freed 700(30KB) AllocSpace objects, 0(0B) LOS objects, 792% free, 18MB/21MB, paused 186us total 12.763ms 07-02 16:00:44.545: I/art(198): Explicit concurrent mark sweep GC freed 7(240B) AllocSpace objects, 0(0B) LOS objects, 792% free, 18MB/21MB, paused 198us total 9.465ms 07-02 16:00:44.554: I/art(198): Explicit concurrent mark sweep GC freed 5(160B) AllocSpace objects, 0(0B) LOS objects, 792% free, 18MB/21MB, paused 224us total 9.045ms
  • 18. Dalvik GC Reason ● GC_CONCURRENT ● GC_FOR_MALLOC ● GC_HPROF_DUMP_HEAP ● GC_EXPLICIT ● GC_EXTERNAL_ALLOC D/dalvikvm: <GC_Reason> <Amount_freed>, <Heap_stats>, <External_memory_stats>, <Pause_time>
  • 19. ART GC Reason ● Concurrent ● Alloc ● Explicit ● NativeAlloc ● CollectorTransition ● HomogeneousSpaceCompact I/art: <GC_Reason> <GC_Name> <Objects_freed>(<Size_freed>) AllocSpace Objects, Large_objects_freed> (<Large_object_size_freed>) <Heap_stats> LOS objects, <Pause_time(s)>
  • 20. Tools
  • 21. Tools ● adb shell dumpsys meminfo <package_name | pid> ● Android Monitor ○ Heap Dump ○ Allocation Tracker ● Eclipse Memory Analyzer Tool (MAT) ● LeakCanary (Square)
  • 23. ● Do not keep long-lived references to an Activity, Context, View, Drawable... ● Avoid non-static inner classes in an activity if you don’t control their life cycle ● Avoid mutable static fields ● Use Weak References ● Try to not have long living objects ● Use as much as possible application Context instead of Activity ● Remember to call unregisterReceiver() after calling registerReceiver() ● Implement cancellation policies for background threads ● Use LeakCanary in the QA cycle ● Keep an eye on the heap while the app is running ● Don’t assume GC will clean up all for you! ● Search for memory leaks even when things aren't failing! How to avoid Memory Leaks?
  • 24. ● Use bitmaps with correct resolution ● Recycle the bitmaps more often, instead of just onDestroy() ● Send large files to server by chunks ● Avoid creating unnecessary objects ● Check the available heap of your application ● Coordinate with the system by implementing onTrimMemory() callback ● External libraries should be used carefully ● Use Proguard and zipalign How to avoid OutofMemoryError?
  • 25. References ● http://developer.android.com/intl/ru/training/articles/memory.html ● https://xakep.ru/2014/05/21/excurse-in-android-architecture/ ● https://software.intel.com/en-us/android/articles/art-vs-dalvik-introducing-the-new-android- x86-runtime ● https://software.intel.com/en-us/android/articles/tips-for-optimizing-android-application- memory-usage ● https://android.googlesource.com/platform/art/+/master/runtime/gc/ ● http://developer.android.com/intl/ru/tools/debugging/debugging-memory.html ● http://www.raizlabs.com/dev/2014/03/wrangling-dalvik-memory-management-in-android-part- 1-of-2/ ● https://acadgild.com/blog/analyze-manage-android-devices-memory-allocation-through-ddms- mat/ ● http://developer.android.com/intl/ru/tools/help/am-memory.html ● http://developer.android.com/tools/debugging/debugging-memory.html
  • 26. Q&A