SlideShare une entreprise Scribd logo
1  sur  19
Memory Problems
In Android Programming
Trí Phạm – 2013
techcaotri@gmail.com
Agenda
• 1. Memory problems: Why?
• 2. Android Bitmaps: A closer look and
some tips
• 3. Memory leaking: Demos, Detection
methods and Solutions.
1. MEMORY PROBLEMS:
WHY?
1.1. Memory problem: Why?
• Limited heap size: 16MB, 32MB, 64MB,..
• Usually in decoding or manipulating bitmaps.
Painful in solving memory problem for low-end devices
2. ANDROID BITMAPS:
A CLOSER LOOK AND SOME
TIPS
2.1. Android Bitmaps
• Java object
• Decode in native via Skia library (SkBitmap)
• Allocation:
– Pre Honeycomb (< 3.0): Native heap but “report” size to
Dalvik VM.
– Honeycomb and beyond (>= 3.0): VM/Java heap
2.1. Android Bitmaps (con’t)
• BitmapFactory.java: decodeResource ->.. -> nativeDecodeAsset
• BitmapFactory.cpp: nativeDecodeAsset -> doDecode
2.1. Android Bitmaps (con’t)
• Pixel allocation policy lies within Graphics.cpp:
2.1. Android Bitmaps (con’t)
• Graphics.cpp: createBitmap -> Bitmap.java: Bitmap constructor
• Pre-Honeycomb (< 3.0):
• Honeycomb and beyond (>= 3.0):
2.1. Android Bitmaps (con’t)
• Pre-Gingerbread GC (< 2.3):
– Stop all app’s threads – not stop all applications
– Full heap collection
– Pause times often > 100ms
• Gingerbread and beyond (>= 2.3):
– Mostly concurrent
– Partial collections
– Pause times usually < 5ms
• Garbage collection in Android does no compacting.
2.1. Android Bitmaps (con’t)
• Decode bitmaps bugs on Android Gingerbread and
previous versions ( <= 2.3):
– https://code.google.com/p/android/issues/detail?id=8488
– If the native Bitmap allocation size plus the current
HeapSize (NOT the actually allocated size)
exceeds the limits, native Bitmap allocation will
always fail
2.2. Bitmap cache
• Architecture
2.2. Bitmap cache (con’t)
• Small tips:
– A better version:
• Honeycomb or later: android:largeHeap
3. MEMORY LEAKING: DEMOS,
DETECTION METHODS AND
SOLUTIONS
3.1. Garbage collection
• Basic algorithm: Mark and Sweep
• Does no compacting
• Memory leak ?
3.2. Demo memory leak 1
• Demo 1
• Detection Method: Code Review and
Heuristics
• Solution
3.3. Demo memory leak 2
• Demo 2
• Detection Method: MAT
• Solution
3.4. Common ways to leak
• Context Leak
• Handler Leak or Inner Class leak Outer
• Solution
Q & A

Contenu connexe

En vedette

Tips and tricks to attack memory problem in android programming
Tips and tricks to attack memory problem in android programmingTips and tricks to attack memory problem in android programming
Tips and tricks to attack memory problem in android programmingZalo_app
 
Stream upload and asynchronous job processing in large scale systems
Stream upload and asynchronous job processing  in large scale systemsStream upload and asynchronous job processing  in large scale systems
Stream upload and asynchronous job processing in large scale systemsZalo_app
 
Advance Android Application Development
Advance Android Application DevelopmentAdvance Android Application Development
Advance Android Application DevelopmentRamesh Prasad
 
Android Protips: Advanced Topics for Expert Android App Developers
Android Protips: Advanced Topics for Expert Android App DevelopersAndroid Protips: Advanced Topics for Expert Android App Developers
Android Protips: Advanced Topics for Expert Android App DevelopersReto Meier
 
Reactive programming on Android
Reactive programming on AndroidReactive programming on Android
Reactive programming on AndroidTomáš Kypta
 
Android app development - Java Programming for Android
Android app development - Java Programming for AndroidAndroid app development - Java Programming for Android
Android app development - Java Programming for AndroidOUM SAOKOSAL
 
Reactive Programming on Android - RxAndroid - RxJava
Reactive Programming on Android - RxAndroid - RxJavaReactive Programming on Android - RxAndroid - RxJava
Reactive Programming on Android - RxAndroid - RxJavaAli Muzaffar
 

En vedette (13)

Web Development Fundamentals
Web Development FundamentalsWeb Development Fundamentals
Web Development Fundamentals
 
Tips and tricks to attack memory problem in android programming
Tips and tricks to attack memory problem in android programmingTips and tricks to attack memory problem in android programming
Tips and tricks to attack memory problem in android programming
 
Stream upload and asynchronous job processing in large scale systems
Stream upload and asynchronous job processing  in large scale systemsStream upload and asynchronous job processing  in large scale systems
Stream upload and asynchronous job processing in large scale systems
 
Advance Android Application Development
Advance Android Application DevelopmentAdvance Android Application Development
Advance Android Application Development
 
Coding defines reality
Coding defines realityCoding defines reality
Coding defines reality
 
Android Protips: Advanced Topics for Expert Android App Developers
Android Protips: Advanced Topics for Expert Android App DevelopersAndroid Protips: Advanced Topics for Expert Android App Developers
Android Protips: Advanced Topics for Expert Android App Developers
 
Advance Android Layout Walkthrough
Advance Android Layout WalkthroughAdvance Android Layout Walkthrough
Advance Android Layout Walkthrough
 
Android Programming
Android ProgrammingAndroid Programming
Android Programming
 
Reactive programming on Android
Reactive programming on AndroidReactive programming on Android
Reactive programming on Android
 
Android app development - Java Programming for Android
Android app development - Java Programming for AndroidAndroid app development - Java Programming for Android
Android app development - Java Programming for Android
 
Reactive Programming on Android - RxAndroid - RxJava
Reactive Programming on Android - RxAndroid - RxJavaReactive Programming on Android - RxAndroid - RxJava
Reactive Programming on Android - RxAndroid - RxJava
 
Sto L Pa N@Nfc Academy 2009
Sto L Pa N@Nfc Academy 2009Sto L Pa N@Nfc Academy 2009
Sto L Pa N@Nfc Academy 2009
 
NFC and Android applications
NFC and Android applicationsNFC and Android applications
NFC and Android applications
 

Similaire à Memory problems in android programming

JavaScript all the things - JavaScript fwdays 2018
JavaScript all the things - JavaScript fwdays 2018JavaScript all the things - JavaScript fwdays 2018
JavaScript all the things - JavaScript fwdays 2018Jan Jongboom
 
Memory management in Andoid
Memory management in AndoidMemory management in Andoid
Memory management in AndoidMonkop Inc
 
Android Memory , Where is all My RAM
Android Memory , Where is all My RAM Android Memory , Where is all My RAM
Android Memory , Where is all My RAM Yossi Elkrief
 
Facebook tricks for image handling in Android
Facebook tricks for image handling in AndroidFacebook tricks for image handling in Android
Facebook tricks for image handling in AndroidTyrone Nicholas
 
VMs, Interpreters, JIT
VMs, Interpreters, JITVMs, Interpreters, JIT
VMs, Interpreters, JITMarcus Denker
 
SGP 2023 graduate school - A quick journey into geometry processing
SGP 2023 graduate school - A quick journey into geometry processingSGP 2023 graduate school - A quick journey into geometry processing
SGP 2023 graduate school - A quick journey into geometry processingBruno Levy
 
Modern Engineer’s Troubleshooting Tools, Techniques & Tricks at Confoo 2018
Modern Engineer’s Troubleshooting Tools, Techniques & Tricks at Confoo 2018Modern Engineer’s Troubleshooting Tools, Techniques & Tricks at Confoo 2018
Modern Engineer’s Troubleshooting Tools, Techniques & Tricks at Confoo 2018Tier1app
 
C++ Advanced Memory Management With Allocators
C++ Advanced Memory Management With AllocatorsC++ Advanced Memory Management With Allocators
C++ Advanced Memory Management With AllocatorsGlobalLogic Ukraine
 
Performance Optimization for Sencha Touch
Performance Optimization for Sencha TouchPerformance Optimization for Sencha Touch
Performance Optimization for Sencha TouchSencha
 
hashdays 2011: Tobias Ospelt - Reversing Android Apps - Hacking and cracking ...
hashdays 2011: Tobias Ospelt - Reversing Android Apps - Hacking and cracking ...hashdays 2011: Tobias Ospelt - Reversing Android Apps - Hacking and cracking ...
hashdays 2011: Tobias Ospelt - Reversing Android Apps - Hacking and cracking ...Area41
 
millions-gc-jax-2022.pptx
millions-gc-jax-2022.pptxmillions-gc-jax-2022.pptx
millions-gc-jax-2022.pptxTier1 app
 
Marmalade: bittersweet experience
Marmalade: bittersweet experienceMarmalade: bittersweet experience
Marmalade: bittersweet experienceMax Klyga
 
Computer System Architecture Lecture Note 8.1 primary Memory
Computer System Architecture Lecture Note 8.1 primary MemoryComputer System Architecture Lecture Note 8.1 primary Memory
Computer System Architecture Lecture Note 8.1 primary MemoryBudditha Hettige
 
CICS Memory Objects and MEMLIMIT
 CICS Memory Objects and MEMLIMIT CICS Memory Objects and MEMLIMIT
CICS Memory Objects and MEMLIMITDavid Clancy
 
How to Monitor Microservices
How to Monitor MicroservicesHow to Monitor Microservices
How to Monitor MicroservicesSysdig
 
Marmalade bittersweet experience
Marmalade bittersweet experienceMarmalade bittersweet experience
Marmalade bittersweet experienceAlexander Degtyarev
 
The Good, the Bad and the Ugly things to do with android
The Good, the Bad and the Ugly things to do with androidThe Good, the Bad and the Ugly things to do with android
The Good, the Bad and the Ugly things to do with androidStanojko Markovik
 
this-is-garbage-talk-2022.pptx
this-is-garbage-talk-2022.pptxthis-is-garbage-talk-2022.pptx
this-is-garbage-talk-2022.pptxTier1 app
 
Scaling MongoDB to a Million Collections
Scaling MongoDB to a Million CollectionsScaling MongoDB to a Million Collections
Scaling MongoDB to a Million CollectionsMongoDB
 

Similaire à Memory problems in android programming (20)

JavaScript all the things - JavaScript fwdays 2018
JavaScript all the things - JavaScript fwdays 2018JavaScript all the things - JavaScript fwdays 2018
JavaScript all the things - JavaScript fwdays 2018
 
Memory management in Andoid
Memory management in AndoidMemory management in Andoid
Memory management in Andoid
 
Android Memory , Where is all My RAM
Android Memory , Where is all My RAM Android Memory , Where is all My RAM
Android Memory , Where is all My RAM
 
Facebook tricks for image handling in Android
Facebook tricks for image handling in AndroidFacebook tricks for image handling in Android
Facebook tricks for image handling in Android
 
VMs, Interpreters, JIT
VMs, Interpreters, JITVMs, Interpreters, JIT
VMs, Interpreters, JIT
 
SGP 2023 graduate school - A quick journey into geometry processing
SGP 2023 graduate school - A quick journey into geometry processingSGP 2023 graduate school - A quick journey into geometry processing
SGP 2023 graduate school - A quick journey into geometry processing
 
Modern Engineer’s Troubleshooting Tools, Techniques & Tricks at Confoo 2018
Modern Engineer’s Troubleshooting Tools, Techniques & Tricks at Confoo 2018Modern Engineer’s Troubleshooting Tools, Techniques & Tricks at Confoo 2018
Modern Engineer’s Troubleshooting Tools, Techniques & Tricks at Confoo 2018
 
C++ Advanced Memory Management With Allocators
C++ Advanced Memory Management With AllocatorsC++ Advanced Memory Management With Allocators
C++ Advanced Memory Management With Allocators
 
Performance Optimization for Sencha Touch
Performance Optimization for Sencha TouchPerformance Optimization for Sencha Touch
Performance Optimization for Sencha Touch
 
hashdays 2011: Tobias Ospelt - Reversing Android Apps - Hacking and cracking ...
hashdays 2011: Tobias Ospelt - Reversing Android Apps - Hacking and cracking ...hashdays 2011: Tobias Ospelt - Reversing Android Apps - Hacking and cracking ...
hashdays 2011: Tobias Ospelt - Reversing Android Apps - Hacking and cracking ...
 
millions-gc-jax-2022.pptx
millions-gc-jax-2022.pptxmillions-gc-jax-2022.pptx
millions-gc-jax-2022.pptx
 
Marmalade: bittersweet experience
Marmalade: bittersweet experienceMarmalade: bittersweet experience
Marmalade: bittersweet experience
 
Computer System Architecture Lecture Note 8.1 primary Memory
Computer System Architecture Lecture Note 8.1 primary MemoryComputer System Architecture Lecture Note 8.1 primary Memory
Computer System Architecture Lecture Note 8.1 primary Memory
 
Deployment
DeploymentDeployment
Deployment
 
CICS Memory Objects and MEMLIMIT
 CICS Memory Objects and MEMLIMIT CICS Memory Objects and MEMLIMIT
CICS Memory Objects and MEMLIMIT
 
How to Monitor Microservices
How to Monitor MicroservicesHow to Monitor Microservices
How to Monitor Microservices
 
Marmalade bittersweet experience
Marmalade bittersweet experienceMarmalade bittersweet experience
Marmalade bittersweet experience
 
The Good, the Bad and the Ugly things to do with android
The Good, the Bad and the Ugly things to do with androidThe Good, the Bad and the Ugly things to do with android
The Good, the Bad and the Ugly things to do with android
 
this-is-garbage-talk-2022.pptx
this-is-garbage-talk-2022.pptxthis-is-garbage-talk-2022.pptx
this-is-garbage-talk-2022.pptx
 
Scaling MongoDB to a Million Collections
Scaling MongoDB to a Million CollectionsScaling MongoDB to a Million Collections
Scaling MongoDB to a Million Collections
 

Plus de AiTi Education

AiTi Education Profile
AiTi Education ProfileAiTi Education Profile
AiTi Education ProfileAiTi Education
 
AiTi Education Software Testing Session 03
AiTi Education Software Testing Session 03AiTi Education Software Testing Session 03
AiTi Education Software Testing Session 03AiTi Education
 
AiTi Education Software Testing Session 02 b
AiTi Education Software Testing Session 02 bAiTi Education Software Testing Session 02 b
AiTi Education Software Testing Session 02 bAiTi Education
 
AiTi Education Software Testing Session 02 a
AiTi Education Software Testing Session 02 aAiTi Education Software Testing Session 02 a
AiTi Education Software Testing Session 02 aAiTi Education
 
AiTi Education Software Testing Session 01 b
AiTi Education Software Testing Session 01 bAiTi Education Software Testing Session 01 b
AiTi Education Software Testing Session 01 bAiTi Education
 
AiTi Education Software Testing Session 01 a
AiTi Education Software Testing Session 01 aAiTi Education Software Testing Session 01 a
AiTi Education Software Testing Session 01 aAiTi Education
 
Vietnam mobile internet_2014_mwork_vietnam_mobile_day
Vietnam mobile internet_2014_mwork_vietnam_mobile_dayVietnam mobile internet_2014_mwork_vietnam_mobile_day
Vietnam mobile internet_2014_mwork_vietnam_mobile_dayAiTi Education
 
[Vietnam Mobile Day 2014] Tăng doanh thu quảng cáo cho mobile site và ứng dụn...
[Vietnam Mobile Day 2014] Tăng doanh thu quảng cáo cho mobile site và ứng dụn...[Vietnam Mobile Day 2014] Tăng doanh thu quảng cáo cho mobile site và ứng dụn...
[Vietnam Mobile Day 2014] Tăng doanh thu quảng cáo cho mobile site và ứng dụn...AiTi Education
 
[Vietnam Mobile Day 2014] Mobile money - Xu hướng thanh toán nhỏ trên mobile ...
[Vietnam Mobile Day 2014] Mobile money - Xu hướng thanh toán nhỏ trên mobile ...[Vietnam Mobile Day 2014] Mobile money - Xu hướng thanh toán nhỏ trên mobile ...
[Vietnam Mobile Day 2014] Mobile money - Xu hướng thanh toán nhỏ trên mobile ...AiTi Education
 
[Vietnam Mobile Day 2014] Mobile kết nối thế giới số và thế giới thực và vai ...
[Vietnam Mobile Day 2014] Mobile kết nối thế giới số và thế giới thực và vai ...[Vietnam Mobile Day 2014] Mobile kết nối thế giới số và thế giới thực và vai ...
[Vietnam Mobile Day 2014] Mobile kết nối thế giới số và thế giới thực và vai ...AiTi Education
 
[Vietnam Mobile Day 2014] The new mobile marketing channel: Social Wifi Marke...
[Vietnam Mobile Day 2014] The new mobile marketing channel: Social Wifi Marke...[Vietnam Mobile Day 2014] The new mobile marketing channel: Social Wifi Marke...
[Vietnam Mobile Day 2014] The new mobile marketing channel: Social Wifi Marke...AiTi Education
 
[Vietnam Mobile Day 2014] Cá nhân hóa và xác định Khách hàng mục tiêu trong q...
[Vietnam Mobile Day 2014] Cá nhân hóa và xác định Khách hàng mục tiêu trong q...[Vietnam Mobile Day 2014] Cá nhân hóa và xác định Khách hàng mục tiêu trong q...
[Vietnam Mobile Day 2014] Cá nhân hóa và xác định Khách hàng mục tiêu trong q...AiTi Education
 
[Vietnam Mobile Day 2014] Chiến lược thu hút người dùng cho ứng dụng tại thị ...
[Vietnam Mobile Day 2014] Chiến lược thu hút người dùng cho ứng dụng tại thị ...[Vietnam Mobile Day 2014] Chiến lược thu hút người dùng cho ứng dụng tại thị ...
[Vietnam Mobile Day 2014] Chiến lược thu hút người dùng cho ứng dụng tại thị ...AiTi Education
 
[Vietnam Mobile Day 2014] Thanh toán mobile, hiện tại và xu hướng- Nguyễn Chi...
[Vietnam Mobile Day 2014] Thanh toán mobile, hiện tại và xu hướng- Nguyễn Chi...[Vietnam Mobile Day 2014] Thanh toán mobile, hiện tại và xu hướng- Nguyễn Chi...
[Vietnam Mobile Day 2014] Thanh toán mobile, hiện tại và xu hướng- Nguyễn Chi...AiTi Education
 
[Vietnam Mobile Day 2014] Thanh toán bằng thẻ ngân hàng trên mobile chưa bao ...
[Vietnam Mobile Day 2014] Thanh toán bằng thẻ ngân hàng trên mobile chưa bao ...[Vietnam Mobile Day 2014] Thanh toán bằng thẻ ngân hàng trên mobile chưa bao ...
[Vietnam Mobile Day 2014] Thanh toán bằng thẻ ngân hàng trên mobile chưa bao ...AiTi Education
 
[Vietnam Mobile Day 2014] How to build a mobile store app in 5 minutes - Ng...
[Vietnam Mobile Day 2014] How to build a mobile store app in 5 minutes - 	 Ng...[Vietnam Mobile Day 2014] How to build a mobile store app in 5 minutes - 	 Ng...
[Vietnam Mobile Day 2014] How to build a mobile store app in 5 minutes - Ng...AiTi Education
 
[Vietnam Mobile Day 2014] Touch the future of the web - Nguyễn Việt Anh - Cou...
[Vietnam Mobile Day 2014] Touch the future of the web - Nguyễn Việt Anh - Cou...[Vietnam Mobile Day 2014] Touch the future of the web - Nguyễn Việt Anh - Cou...
[Vietnam Mobile Day 2014] Touch the future of the web - Nguyễn Việt Anh - Cou...AiTi Education
 
[Vietnam Mobile Day 2014] Xu hướng trong Mobile Learning, 2014 - Nguyễn Thàn...
[Vietnam Mobile Day 2014] Xu hướng trong Mobile Learning, 2014  - Nguyễn Thàn...[Vietnam Mobile Day 2014] Xu hướng trong Mobile Learning, 2014  - Nguyễn Thàn...
[Vietnam Mobile Day 2014] Xu hướng trong Mobile Learning, 2014 - Nguyễn Thàn...AiTi Education
 
[Vietnam Mobile Day 2014] Toàn cảnh thị trường game smartphone Việt Nam 2013....
[Vietnam Mobile Day 2014] Toàn cảnh thị trường game smartphone Việt Nam 2013....[Vietnam Mobile Day 2014] Toàn cảnh thị trường game smartphone Việt Nam 2013....
[Vietnam Mobile Day 2014] Toàn cảnh thị trường game smartphone Việt Nam 2013....AiTi Education
 
[Vietnam Mobile Day 2014] Toàn cảnh thị trường game smartphone Việt Nam 2013....
[Vietnam Mobile Day 2014] Toàn cảnh thị trường game smartphone Việt Nam 2013....[Vietnam Mobile Day 2014] Toàn cảnh thị trường game smartphone Việt Nam 2013....
[Vietnam Mobile Day 2014] Toàn cảnh thị trường game smartphone Việt Nam 2013....AiTi Education
 

Plus de AiTi Education (20)

AiTi Education Profile
AiTi Education ProfileAiTi Education Profile
AiTi Education Profile
 
AiTi Education Software Testing Session 03
AiTi Education Software Testing Session 03AiTi Education Software Testing Session 03
AiTi Education Software Testing Session 03
 
AiTi Education Software Testing Session 02 b
AiTi Education Software Testing Session 02 bAiTi Education Software Testing Session 02 b
AiTi Education Software Testing Session 02 b
 
AiTi Education Software Testing Session 02 a
AiTi Education Software Testing Session 02 aAiTi Education Software Testing Session 02 a
AiTi Education Software Testing Session 02 a
 
AiTi Education Software Testing Session 01 b
AiTi Education Software Testing Session 01 bAiTi Education Software Testing Session 01 b
AiTi Education Software Testing Session 01 b
 
AiTi Education Software Testing Session 01 a
AiTi Education Software Testing Session 01 aAiTi Education Software Testing Session 01 a
AiTi Education Software Testing Session 01 a
 
Vietnam mobile internet_2014_mwork_vietnam_mobile_day
Vietnam mobile internet_2014_mwork_vietnam_mobile_dayVietnam mobile internet_2014_mwork_vietnam_mobile_day
Vietnam mobile internet_2014_mwork_vietnam_mobile_day
 
[Vietnam Mobile Day 2014] Tăng doanh thu quảng cáo cho mobile site và ứng dụn...
[Vietnam Mobile Day 2014] Tăng doanh thu quảng cáo cho mobile site và ứng dụn...[Vietnam Mobile Day 2014] Tăng doanh thu quảng cáo cho mobile site và ứng dụn...
[Vietnam Mobile Day 2014] Tăng doanh thu quảng cáo cho mobile site và ứng dụn...
 
[Vietnam Mobile Day 2014] Mobile money - Xu hướng thanh toán nhỏ trên mobile ...
[Vietnam Mobile Day 2014] Mobile money - Xu hướng thanh toán nhỏ trên mobile ...[Vietnam Mobile Day 2014] Mobile money - Xu hướng thanh toán nhỏ trên mobile ...
[Vietnam Mobile Day 2014] Mobile money - Xu hướng thanh toán nhỏ trên mobile ...
 
[Vietnam Mobile Day 2014] Mobile kết nối thế giới số và thế giới thực và vai ...
[Vietnam Mobile Day 2014] Mobile kết nối thế giới số và thế giới thực và vai ...[Vietnam Mobile Day 2014] Mobile kết nối thế giới số và thế giới thực và vai ...
[Vietnam Mobile Day 2014] Mobile kết nối thế giới số và thế giới thực và vai ...
 
[Vietnam Mobile Day 2014] The new mobile marketing channel: Social Wifi Marke...
[Vietnam Mobile Day 2014] The new mobile marketing channel: Social Wifi Marke...[Vietnam Mobile Day 2014] The new mobile marketing channel: Social Wifi Marke...
[Vietnam Mobile Day 2014] The new mobile marketing channel: Social Wifi Marke...
 
[Vietnam Mobile Day 2014] Cá nhân hóa và xác định Khách hàng mục tiêu trong q...
[Vietnam Mobile Day 2014] Cá nhân hóa và xác định Khách hàng mục tiêu trong q...[Vietnam Mobile Day 2014] Cá nhân hóa và xác định Khách hàng mục tiêu trong q...
[Vietnam Mobile Day 2014] Cá nhân hóa và xác định Khách hàng mục tiêu trong q...
 
[Vietnam Mobile Day 2014] Chiến lược thu hút người dùng cho ứng dụng tại thị ...
[Vietnam Mobile Day 2014] Chiến lược thu hút người dùng cho ứng dụng tại thị ...[Vietnam Mobile Day 2014] Chiến lược thu hút người dùng cho ứng dụng tại thị ...
[Vietnam Mobile Day 2014] Chiến lược thu hút người dùng cho ứng dụng tại thị ...
 
[Vietnam Mobile Day 2014] Thanh toán mobile, hiện tại và xu hướng- Nguyễn Chi...
[Vietnam Mobile Day 2014] Thanh toán mobile, hiện tại và xu hướng- Nguyễn Chi...[Vietnam Mobile Day 2014] Thanh toán mobile, hiện tại và xu hướng- Nguyễn Chi...
[Vietnam Mobile Day 2014] Thanh toán mobile, hiện tại và xu hướng- Nguyễn Chi...
 
[Vietnam Mobile Day 2014] Thanh toán bằng thẻ ngân hàng trên mobile chưa bao ...
[Vietnam Mobile Day 2014] Thanh toán bằng thẻ ngân hàng trên mobile chưa bao ...[Vietnam Mobile Day 2014] Thanh toán bằng thẻ ngân hàng trên mobile chưa bao ...
[Vietnam Mobile Day 2014] Thanh toán bằng thẻ ngân hàng trên mobile chưa bao ...
 
[Vietnam Mobile Day 2014] How to build a mobile store app in 5 minutes - Ng...
[Vietnam Mobile Day 2014] How to build a mobile store app in 5 minutes - 	 Ng...[Vietnam Mobile Day 2014] How to build a mobile store app in 5 minutes - 	 Ng...
[Vietnam Mobile Day 2014] How to build a mobile store app in 5 minutes - Ng...
 
[Vietnam Mobile Day 2014] Touch the future of the web - Nguyễn Việt Anh - Cou...
[Vietnam Mobile Day 2014] Touch the future of the web - Nguyễn Việt Anh - Cou...[Vietnam Mobile Day 2014] Touch the future of the web - Nguyễn Việt Anh - Cou...
[Vietnam Mobile Day 2014] Touch the future of the web - Nguyễn Việt Anh - Cou...
 
[Vietnam Mobile Day 2014] Xu hướng trong Mobile Learning, 2014 - Nguyễn Thàn...
[Vietnam Mobile Day 2014] Xu hướng trong Mobile Learning, 2014  - Nguyễn Thàn...[Vietnam Mobile Day 2014] Xu hướng trong Mobile Learning, 2014  - Nguyễn Thàn...
[Vietnam Mobile Day 2014] Xu hướng trong Mobile Learning, 2014 - Nguyễn Thàn...
 
[Vietnam Mobile Day 2014] Toàn cảnh thị trường game smartphone Việt Nam 2013....
[Vietnam Mobile Day 2014] Toàn cảnh thị trường game smartphone Việt Nam 2013....[Vietnam Mobile Day 2014] Toàn cảnh thị trường game smartphone Việt Nam 2013....
[Vietnam Mobile Day 2014] Toàn cảnh thị trường game smartphone Việt Nam 2013....
 
[Vietnam Mobile Day 2014] Toàn cảnh thị trường game smartphone Việt Nam 2013....
[Vietnam Mobile Day 2014] Toàn cảnh thị trường game smartphone Việt Nam 2013....[Vietnam Mobile Day 2014] Toàn cảnh thị trường game smartphone Việt Nam 2013....
[Vietnam Mobile Day 2014] Toàn cảnh thị trường game smartphone Việt Nam 2013....
 

Dernier

Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 

Dernier (20)

Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 

Memory problems in android programming

  • 1. Memory Problems In Android Programming Trí Phạm – 2013 techcaotri@gmail.com
  • 2. Agenda • 1. Memory problems: Why? • 2. Android Bitmaps: A closer look and some tips • 3. Memory leaking: Demos, Detection methods and Solutions.
  • 4. 1.1. Memory problem: Why? • Limited heap size: 16MB, 32MB, 64MB,.. • Usually in decoding or manipulating bitmaps. Painful in solving memory problem for low-end devices
  • 5. 2. ANDROID BITMAPS: A CLOSER LOOK AND SOME TIPS
  • 6. 2.1. Android Bitmaps • Java object • Decode in native via Skia library (SkBitmap) • Allocation: – Pre Honeycomb (< 3.0): Native heap but “report” size to Dalvik VM. – Honeycomb and beyond (>= 3.0): VM/Java heap
  • 7. 2.1. Android Bitmaps (con’t) • BitmapFactory.java: decodeResource ->.. -> nativeDecodeAsset • BitmapFactory.cpp: nativeDecodeAsset -> doDecode
  • 8. 2.1. Android Bitmaps (con’t) • Pixel allocation policy lies within Graphics.cpp:
  • 9. 2.1. Android Bitmaps (con’t) • Graphics.cpp: createBitmap -> Bitmap.java: Bitmap constructor • Pre-Honeycomb (< 3.0): • Honeycomb and beyond (>= 3.0):
  • 10. 2.1. Android Bitmaps (con’t) • Pre-Gingerbread GC (< 2.3): – Stop all app’s threads – not stop all applications – Full heap collection – Pause times often > 100ms • Gingerbread and beyond (>= 2.3): – Mostly concurrent – Partial collections – Pause times usually < 5ms • Garbage collection in Android does no compacting.
  • 11. 2.1. Android Bitmaps (con’t) • Decode bitmaps bugs on Android Gingerbread and previous versions ( <= 2.3): – https://code.google.com/p/android/issues/detail?id=8488 – If the native Bitmap allocation size plus the current HeapSize (NOT the actually allocated size) exceeds the limits, native Bitmap allocation will always fail
  • 12. 2.2. Bitmap cache • Architecture
  • 13. 2.2. Bitmap cache (con’t) • Small tips: – A better version: • Honeycomb or later: android:largeHeap
  • 14. 3. MEMORY LEAKING: DEMOS, DETECTION METHODS AND SOLUTIONS
  • 15. 3.1. Garbage collection • Basic algorithm: Mark and Sweep • Does no compacting • Memory leak ?
  • 16. 3.2. Demo memory leak 1 • Demo 1 • Detection Method: Code Review and Heuristics • Solution
  • 17. 3.3. Demo memory leak 2 • Demo 2 • Detection Method: MAT • Solution
  • 18. 3.4. Common ways to leak • Context Leak • Handler Leak or Inner Class leak Outer • Solution
  • 19. Q & A