SlideShare a Scribd company logo
1 of 28
Group Presentation
Semester: Fall-2017
Course: Operating Systems Design
Section: 04
Instructor: Dr. Nova Ahmed
Memory Management of Android OS
151034204
2151138464
2
1511109042
1410542042
MEMBERS
Md. Asif Khan
Mohammad Rashedul
Alam
Sadman Kabir Soumik
Pias Paul
INTRODUCTION
Android is a Linux based OS with 2.6.x kernel which has
been stripped down to handle most tasks pretty well.
It uses native open source C libraries that have powered
Linux machines for years.
The Android SDK provides the tools and API’s necessary to begin developing applications
on the Android platform using the Java programming language.
All the basic OS operations like I/O, memory management, and so on, are
handled by the native Linux kernel.
Overview of Android Memory Management
The Android Runtime (ART) and Dalvik virtual machine
use paging and memory-mapping (mmapping) to manage memory.
Android does not support swapping
Flash memory can only be written to a limited number of times
before it becomes unreliable
It uses flash memory for persistent storage like the hard drives in
a desktop, so there is not as much space available
The bandwidth to flash memory is lower
WHAT IS MEMORY MAPPING?
Memory mapping is
used to map image and
data files into a
processes address
space.
In memory mapping, the
contents of a file are linked
directly into the virtual
address space of a process.
DALVIK VIRTUAL MACHINE
It executes applications written for android
Dalvik is the process virtual machine in Google’s android
operating system
Multiple Instances of the VM running. Like a specialized
java VM
DALVIK VIRTUAL MACHINE
MEMORY MANAGEMENT TECHNIQUE
So, why
should
we care
about
the
memory?
It executes applications written for android
Heap size is limited and device dependent
Multiple Instances of the VM running. Like a specialized
java VM
Multiple Instances of the VM running. Like a specialized
java VM and Battery life.
VIRTUAL MEMORY
In computing, virtual memory (also virtual storage) is a
memory management technique that provides an "idealized
abstraction of the storage resources that are actually
available on a given machine" which "creates the illusion to
users of a very large (main) memory."
The computer's OS using a combination of hardware and software, maps
memory addresses used by a program, called virtual addresses, into
physical addresses in computer memory. Main storage, as seen by a
process or task, appears as a contiguous address space or collection of
contiguous segments. The operating system manages virtual address
spaces and the assignment of real memory to virtual memory. Address
translation hardware in the CPU, often referred to as a memory
management unit or MMU, automatically translates virtual addresses to
physical addresses.
VIRTUAL MEMORY-KEY BENEFITS
More security and Isolation
Avoid Process to handle a shared space.
More memory available
Easier programming/hidden fragmentation
VIRTUAL MEMORY-KEY BENEFITS
GARBAGE COLLECTION
Garbage collection has two goals: find data objects in a program that cannot
be accessed in the future; and reclaim the resources used by those objects.
So, garbage collection can be triggered
when an allocation fails
when the size of the heap hits some soft limit
when a GC was explicitly requested.
OutOfMemoryError is about to be triggered
GARBAGE COLLECTION
It is the
mechanism for
reclaiming
unused memory
environment.
It is a
predefined
event.
The key point is: Android
memory heap has
different buckets of
allocations that it tracks
based on the expected life
and size of an object being
allocated.
For example-> recently
allocated objects belong in
the young generation
,when an object stays
active long enough it can
be promoted to the older
generation –followed by a
permanent generation.
• The actual GC is done using a Mark-Sweep Algorithm
SHARING MEMORY
In order to fit everything it needs in RAM, Android tries to share RAM pages across
processes. It can do so in the following ways:
2. Most static data is mmapped into a process.
1. Each app process is forked from an existing process called
Zygote. Zygote is Android’s core process that starts up at
init .It is the initial cell formed when a new organism is
produced.
3. In many places, Android shares the same dynamic RAM
across processes using explicitly allocated shared memory
regions.
ALLOCATING AND RECLAIMING APP MEMORY
Here are some facts about how Android
allocates then reclaims memory from
your app:
• The Dalvik heap for each process is
constrained to a single virtual memory
range. This defines the logical heap
size, which can grow as it needs to (but
only up to a limit that the system
defines for each app).
ALLOCATING AND RECLAIMING APP MEMORY
The Dalvik heap does not compact the logical size of the heap, meaning that Android does not
defragment the heap to close up space. Android can only shrink the logical heap size when there
is unused space at the end of the heap.
• But this doesn't mean the physical memory used by the heap can't shrink. After garbage
collection, Dalvik walks the heap and finds unused pages, then returns those pages to the kernel
using ‘madvise()’.
So,the point is paired allocations and deallocations of large chunks should result in reclaiming
all (or nearly all) the physical memory used. However, reclaiming memory from small allocations
can be much less efficient because the page used for a small allocation may still be shared with
something else that has not yet been freed.
• To maintain a functional multi-tasking environment, Android sets a hard limit on the heap size for
each app. The exact heap size limit varies between devices based on how much RAM the device has
available overall.
• If your app has reached the heap capacity and tries to allocate more memory, it will receive an
OutOfMemoryError.
• You might want to query the system to determine exactly how much heap space you have available
on the current device—for example, to determine how much data is safe to keep in a cache. You can
query the system for this figure by calling getMemoryClass(). This returns an integer indicating the
number of megabytes available for your app's heap.
Restricting App Memory
 When the user switches between apps, Android keeps processes that are not
hosting a foreground ("user visible") app component in a least-recently used
(LRU) cache.
 For example, when the user first launches an app, a process is created for it,
but when the user leaves the app, that process does not quit. The system keeps
the process cached, so if the user later returns to the app, the process is reused
for faster app switching.
Switching Apps
 If your app has a cached process and it retains memory that it currently does
not need, then your app even while the user is not using it is affecting the
system's overall performance.
 So, as the system runs low on memory, it may kill processes in the LRU cache
beginning with the process least recently used, but also giving some
consideration toward which processes are most memory intensive.
Switching Apps
Process Management
A process is a program in execution. A
process needs certain resources, including
CPU time, memory, files, and I/O devices, to
accomplish its task.
Process
 When an application component starts and the
application doesn’t have any other components running,
the Android system starts a new Linux process for the
application with a single thread of execution.
 By default all components of the same application run in
the same process and thread(main() thread).
Foreground
Process
An acivitiy which is
interacting with user. When
an activity calls methods like
onstart(), onresume().
When a service is executing
any of the methods like
onCreate(), onStart(),
onDestroy().
Background
Process
When an acivity running
method like onStop(). i.e
currently user is not
interacting with that activity.
System maintains LRU list of
background process.
Whenever a process decided
to kill, it stores the state of
activity. So whenever next
user wants that activity, we
can restore the previous
state of activity.
Visible
Process
An acivitiy which is not
interacting with user. But it is
still visible to user, when an
acivity running method like
onPause().
When a service is interacting
with visible acitvity.
Service
Process
When a service is started
using startService().
Eg: playing music in
background, downloading file
from internet.
Empty
Process
When a process does not
have any active component.
Caching of empty process
inside memory, reduces
relaunching of applicaiton
once again if user wants that
applicaiton in future.
Process Life Cycle in Android
COMPARISON OF MM BETWEEN ANDROID AND AN OTHER OS (WINDOWS)
Android Windows
To stress the memory management of the Android, an app
creates multiple foreground activities to allocate memory
resources.
Windows supports virtual memory and can run more
programs than there is RAM to hold.
High memory and CPU usage. Low memory and CPU usage.
Android is an open source platform, meaning that the
operating system is available for modification by
manufacturers to suit their respective needs and phones.
Microsoft Windows is closed-sourced, meaning that it is
owned and managed by Microsoft and developers do not
have direct access to the operating system programming
code.
The Android system does not allow the machine to be
overcommitted and will terminate idle apps to free memory.
In Windows, the main memory is saturated, the virtual
memory system starts to thrash and performance is greatly
degraded. The programs will run, but very slowly.
The library is divided in to two components: Android
Runtime and Android Library. Android Runtime is consisted
of a Java Core Library and Dalvik Virtual Machine.
The core operating system (OS) services consist of the kernel
and other features. Core OS services enable low-level tasks,
such as process, thread, and memory management. Basic
device drivers are also part of the Core OS services.
Supported CPU architectures: ARM, x86, MIPS and the 64-bit
variants of all three.
Supported CPU architecture: ARM
SUMMARY
 Android is based on a Linux kernel that uses APIs to give
access to system calls.
 Android uses its own virtual machine called DalvikVM to
ensure that multiple processes can run at the same time.
 The memory management in Android is based on the
priority of the processes that are currently running.
 Processes are killed following this priority hierarchy to
maintain overall memory management
References
http://www.geeksforgeeks.org/mark-and-sweep-garbage-collection-
algorithm/
https://developer.android.com/…/perfor…/memory-overview.html
https://developer.android.com/topic/performance/memory.html
https://www.androidpit.com/how-to-manage-memory-on-android
Thanks Everyone for Listening
If you have any Questions, feel free to ask…

More Related Content

What's hot

INTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptxINTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptxLECO9
 
Chapter 13 software testing strategies
Chapter 13 software testing strategiesChapter 13 software testing strategies
Chapter 13 software testing strategiesSHREEHARI WADAWADAGI
 
Remote invocation
Remote invocationRemote invocation
Remote invocationishapadhy
 
Operating system services 9
Operating system services 9Operating system services 9
Operating system services 9myrajendra
 
Flow oriented modeling
Flow oriented modelingFlow oriented modeling
Flow oriented modelingramyaaswin
 
Message passing ( in computer science)
Message   passing  ( in   computer  science)Message   passing  ( in   computer  science)
Message passing ( in computer science)Computer_ at_home
 
Java awt (abstract window toolkit)
Java awt (abstract window toolkit)Java awt (abstract window toolkit)
Java awt (abstract window toolkit)Elizabeth alexander
 
Introduction to Virtualization
Introduction to VirtualizationIntroduction to Virtualization
Introduction to VirtualizationRahul Hada
 
deadlock avoidance
deadlock avoidancedeadlock avoidance
deadlock avoidancewahab13
 
Distributed operating system
Distributed operating systemDistributed operating system
Distributed operating systemPrankit Mishra
 
Parallel programming model, language and compiler in ACA.
Parallel programming model, language and compiler in ACA.Parallel programming model, language and compiler in ACA.
Parallel programming model, language and compiler in ACA.MITS Gwalior
 
Feng’s classification
Feng’s classificationFeng’s classification
Feng’s classificationNarayan Kandel
 
The Object Model
The Object Model  The Object Model
The Object Model yndaravind
 
Networking threads
Networking threadsNetworking threads
Networking threadsNilesh Pawar
 
Operating Systems - "Chapter 4: Multithreaded Programming"
Operating Systems - "Chapter 4:  Multithreaded Programming"Operating Systems - "Chapter 4:  Multithreaded Programming"
Operating Systems - "Chapter 4: Multithreaded Programming"Ra'Fat Al-Msie'deen
 

What's hot (20)

INTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptxINTER PROCESS COMMUNICATION (IPC).pptx
INTER PROCESS COMMUNICATION (IPC).pptx
 
File sharing
File sharingFile sharing
File sharing
 
Component based software engineering
Component based software engineeringComponent based software engineering
Component based software engineering
 
Chapter 13 software testing strategies
Chapter 13 software testing strategiesChapter 13 software testing strategies
Chapter 13 software testing strategies
 
Remote invocation
Remote invocationRemote invocation
Remote invocation
 
Virtual machine security
Virtual machine securityVirtual machine security
Virtual machine security
 
Operating system services 9
Operating system services 9Operating system services 9
Operating system services 9
 
Flow oriented modeling
Flow oriented modelingFlow oriented modeling
Flow oriented modeling
 
Message passing ( in computer science)
Message   passing  ( in   computer  science)Message   passing  ( in   computer  science)
Message passing ( in computer science)
 
Java awt (abstract window toolkit)
Java awt (abstract window toolkit)Java awt (abstract window toolkit)
Java awt (abstract window toolkit)
 
Introduction to Virtualization
Introduction to VirtualizationIntroduction to Virtualization
Introduction to Virtualization
 
deadlock avoidance
deadlock avoidancedeadlock avoidance
deadlock avoidance
 
Distributed operating system
Distributed operating systemDistributed operating system
Distributed operating system
 
Parallel programming model, language and compiler in ACA.
Parallel programming model, language and compiler in ACA.Parallel programming model, language and compiler in ACA.
Parallel programming model, language and compiler in ACA.
 
Virtualization in cloud computing
Virtualization in cloud computingVirtualization in cloud computing
Virtualization in cloud computing
 
Feng’s classification
Feng’s classificationFeng’s classification
Feng’s classification
 
The Object Model
The Object Model  The Object Model
The Object Model
 
Networking threads
Networking threadsNetworking threads
Networking threads
 
Operating Systems - "Chapter 4: Multithreaded Programming"
Operating Systems - "Chapter 4:  Multithreaded Programming"Operating Systems - "Chapter 4:  Multithreaded Programming"
Operating Systems - "Chapter 4: Multithreaded Programming"
 
Shared memory
Shared memoryShared memory
Shared memory
 

Similar to Android Memory Management

ACADGILD:: ANDROID LESSON-How to analyze & manage memory on android like ...
ACADGILD:: ANDROID LESSON-How to analyze & manage memory on android like ...ACADGILD:: ANDROID LESSON-How to analyze & manage memory on android like ...
ACADGILD:: ANDROID LESSON-How to analyze & manage memory on android like ...Padma shree. T
 
Android Performance Best Practices
Android Performance Best Practices Android Performance Best Practices
Android Performance Best Practices Amgad Muhammad
 
virtual memory.ppt
virtual memory.pptvirtual memory.ppt
virtual memory.pptsuryansh85
 
NOV11 virtual memory.ppt
NOV11 virtual memory.pptNOV11 virtual memory.ppt
NOV11 virtual memory.pptPratikBose10
 
Operating systems
Operating systemsOperating systems
Operating systemsoswaldm80
 
Chapter 2 part 1
Chapter 2 part 1Chapter 2 part 1
Chapter 2 part 1rohassanie
 
Chapter 09 - Virtual Memory.ppt
Chapter 09 - Virtual Memory.pptChapter 09 - Virtual Memory.ppt
Chapter 09 - Virtual Memory.pptMonirJihad1
 
Operating Systems Structure1- Explain briefly why the objectives o.pdf
Operating Systems Structure1- Explain briefly why the objectives o.pdfOperating Systems Structure1- Explain briefly why the objectives o.pdf
Operating Systems Structure1- Explain briefly why the objectives o.pdfrishabjain5053
 
1 Module - Operating Systems Configuration and Use by Mark John Lado
1 Module - Operating Systems Configuration and Use by Mark John Lado1 Module - Operating Systems Configuration and Use by Mark John Lado
1 Module - Operating Systems Configuration and Use by Mark John LadoMark John Lado, MIT
 
Operating system presentation
Operating system presentationOperating system presentation
Operating system presentationSonu Vishwakarma
 
Operating Systems and Memory Management
Operating Systems and Memory ManagementOperating Systems and Memory Management
Operating Systems and Memory Managementguest1415ae65
 
An Efficient Virtual Memory using Graceful Code
An Efficient Virtual Memory using Graceful CodeAn Efficient Virtual Memory using Graceful Code
An Efficient Virtual Memory using Graceful Codeijtsrd
 
OPERATING SYSTEM BY DR .MUGABO MG MKAMA
OPERATING SYSTEM BY DR .MUGABO MG MKAMAOPERATING SYSTEM BY DR .MUGABO MG MKAMA
OPERATING SYSTEM BY DR .MUGABO MG MKAMAMugabo Mkama
 
How to do Memory Optimizations in Android
How to do Memory Optimizations in AndroidHow to do Memory Optimizations in Android
How to do Memory Optimizations in AndroidSingsys Pte Ltd
 
Virtual Memory
Virtual MemoryVirtual Memory
Virtual Memoryvampugani
 
ITFT _ Operating system
ITFT _ Operating systemITFT _ Operating system
ITFT _ Operating systemNavneet Kaur
 
How many total bits are required for a direct-mapped cache with 2048 .pdf
How many total bits are required for a direct-mapped cache with 2048 .pdfHow many total bits are required for a direct-mapped cache with 2048 .pdf
How many total bits are required for a direct-mapped cache with 2048 .pdfEye2eyeopticians10
 

Similar to Android Memory Management (20)

ACADGILD:: ANDROID LESSON-How to analyze & manage memory on android like ...
ACADGILD:: ANDROID LESSON-How to analyze & manage memory on android like ...ACADGILD:: ANDROID LESSON-How to analyze & manage memory on android like ...
ACADGILD:: ANDROID LESSON-How to analyze & manage memory on android like ...
 
Android Performance Best Practices
Android Performance Best Practices Android Performance Best Practices
Android Performance Best Practices
 
Android OS
Android OSAndroid OS
Android OS
 
virtual memory.ppt
virtual memory.pptvirtual memory.ppt
virtual memory.ppt
 
NOV11 virtual memory.ppt
NOV11 virtual memory.pptNOV11 virtual memory.ppt
NOV11 virtual memory.ppt
 
Operating systems
Operating systemsOperating systems
Operating systems
 
Chapter 2 part 1
Chapter 2 part 1Chapter 2 part 1
Chapter 2 part 1
 
Chapter 09 - Virtual Memory.ppt
Chapter 09 - Virtual Memory.pptChapter 09 - Virtual Memory.ppt
Chapter 09 - Virtual Memory.ppt
 
Operating Systems Structure1- Explain briefly why the objectives o.pdf
Operating Systems Structure1- Explain briefly why the objectives o.pdfOperating Systems Structure1- Explain briefly why the objectives o.pdf
Operating Systems Structure1- Explain briefly why the objectives o.pdf
 
NOV11 virtual memory.ppt
NOV11 virtual memory.pptNOV11 virtual memory.ppt
NOV11 virtual memory.ppt
 
1 Module - Operating Systems Configuration and Use by Mark John Lado
1 Module - Operating Systems Configuration and Use by Mark John Lado1 Module - Operating Systems Configuration and Use by Mark John Lado
1 Module - Operating Systems Configuration and Use by Mark John Lado
 
Operating system presentation
Operating system presentationOperating system presentation
Operating system presentation
 
Operating Systems and Memory Management
Operating Systems and Memory ManagementOperating Systems and Memory Management
Operating Systems and Memory Management
 
An Efficient Virtual Memory using Graceful Code
An Efficient Virtual Memory using Graceful CodeAn Efficient Virtual Memory using Graceful Code
An Efficient Virtual Memory using Graceful Code
 
OPERATING SYSTEM BY DR .MUGABO MG MKAMA
OPERATING SYSTEM BY DR .MUGABO MG MKAMAOPERATING SYSTEM BY DR .MUGABO MG MKAMA
OPERATING SYSTEM BY DR .MUGABO MG MKAMA
 
How to do Memory Optimizations in Android
How to do Memory Optimizations in AndroidHow to do Memory Optimizations in Android
How to do Memory Optimizations in Android
 
Virtual Memory
Virtual MemoryVirtual Memory
Virtual Memory
 
ITFT _ Operating system
ITFT _ Operating systemITFT _ Operating system
ITFT _ Operating system
 
Nachos 2
Nachos 2Nachos 2
Nachos 2
 
How many total bits are required for a direct-mapped cache with 2048 .pdf
How many total bits are required for a direct-mapped cache with 2048 .pdfHow many total bits are required for a direct-mapped cache with 2048 .pdf
How many total bits are required for a direct-mapped cache with 2048 .pdf
 

Recently uploaded

main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture designssuser87fa0c1
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 

Recently uploaded (20)

main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
pipeline in computer architecture design
pipeline in computer architecture  designpipeline in computer architecture  design
pipeline in computer architecture design
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 

Android Memory Management

  • 1. Group Presentation Semester: Fall-2017 Course: Operating Systems Design Section: 04 Instructor: Dr. Nova Ahmed Memory Management of Android OS
  • 3. INTRODUCTION Android is a Linux based OS with 2.6.x kernel which has been stripped down to handle most tasks pretty well. It uses native open source C libraries that have powered Linux machines for years. The Android SDK provides the tools and API’s necessary to begin developing applications on the Android platform using the Java programming language. All the basic OS operations like I/O, memory management, and so on, are handled by the native Linux kernel.
  • 4. Overview of Android Memory Management The Android Runtime (ART) and Dalvik virtual machine use paging and memory-mapping (mmapping) to manage memory. Android does not support swapping Flash memory can only be written to a limited number of times before it becomes unreliable It uses flash memory for persistent storage like the hard drives in a desktop, so there is not as much space available The bandwidth to flash memory is lower
  • 5. WHAT IS MEMORY MAPPING? Memory mapping is used to map image and data files into a processes address space. In memory mapping, the contents of a file are linked directly into the virtual address space of a process.
  • 6. DALVIK VIRTUAL MACHINE It executes applications written for android Dalvik is the process virtual machine in Google’s android operating system Multiple Instances of the VM running. Like a specialized java VM
  • 9. So, why should we care about the memory? It executes applications written for android Heap size is limited and device dependent Multiple Instances of the VM running. Like a specialized java VM Multiple Instances of the VM running. Like a specialized java VM and Battery life.
  • 10. VIRTUAL MEMORY In computing, virtual memory (also virtual storage) is a memory management technique that provides an "idealized abstraction of the storage resources that are actually available on a given machine" which "creates the illusion to users of a very large (main) memory." The computer's OS using a combination of hardware and software, maps memory addresses used by a program, called virtual addresses, into physical addresses in computer memory. Main storage, as seen by a process or task, appears as a contiguous address space or collection of contiguous segments. The operating system manages virtual address spaces and the assignment of real memory to virtual memory. Address translation hardware in the CPU, often referred to as a memory management unit or MMU, automatically translates virtual addresses to physical addresses.
  • 11. VIRTUAL MEMORY-KEY BENEFITS More security and Isolation Avoid Process to handle a shared space. More memory available Easier programming/hidden fragmentation
  • 13. GARBAGE COLLECTION Garbage collection has two goals: find data objects in a program that cannot be accessed in the future; and reclaim the resources used by those objects. So, garbage collection can be triggered when an allocation fails when the size of the heap hits some soft limit when a GC was explicitly requested. OutOfMemoryError is about to be triggered
  • 14. GARBAGE COLLECTION It is the mechanism for reclaiming unused memory environment. It is a predefined event. The key point is: Android memory heap has different buckets of allocations that it tracks based on the expected life and size of an object being allocated. For example-> recently allocated objects belong in the young generation ,when an object stays active long enough it can be promoted to the older generation –followed by a permanent generation.
  • 15. • The actual GC is done using a Mark-Sweep Algorithm
  • 16. SHARING MEMORY In order to fit everything it needs in RAM, Android tries to share RAM pages across processes. It can do so in the following ways: 2. Most static data is mmapped into a process. 1. Each app process is forked from an existing process called Zygote. Zygote is Android’s core process that starts up at init .It is the initial cell formed when a new organism is produced. 3. In many places, Android shares the same dynamic RAM across processes using explicitly allocated shared memory regions.
  • 17. ALLOCATING AND RECLAIMING APP MEMORY Here are some facts about how Android allocates then reclaims memory from your app: • The Dalvik heap for each process is constrained to a single virtual memory range. This defines the logical heap size, which can grow as it needs to (but only up to a limit that the system defines for each app).
  • 18. ALLOCATING AND RECLAIMING APP MEMORY The Dalvik heap does not compact the logical size of the heap, meaning that Android does not defragment the heap to close up space. Android can only shrink the logical heap size when there is unused space at the end of the heap. • But this doesn't mean the physical memory used by the heap can't shrink. After garbage collection, Dalvik walks the heap and finds unused pages, then returns those pages to the kernel using ‘madvise()’. So,the point is paired allocations and deallocations of large chunks should result in reclaiming all (or nearly all) the physical memory used. However, reclaiming memory from small allocations can be much less efficient because the page used for a small allocation may still be shared with something else that has not yet been freed.
  • 19. • To maintain a functional multi-tasking environment, Android sets a hard limit on the heap size for each app. The exact heap size limit varies between devices based on how much RAM the device has available overall. • If your app has reached the heap capacity and tries to allocate more memory, it will receive an OutOfMemoryError. • You might want to query the system to determine exactly how much heap space you have available on the current device—for example, to determine how much data is safe to keep in a cache. You can query the system for this figure by calling getMemoryClass(). This returns an integer indicating the number of megabytes available for your app's heap. Restricting App Memory
  • 20.  When the user switches between apps, Android keeps processes that are not hosting a foreground ("user visible") app component in a least-recently used (LRU) cache.  For example, when the user first launches an app, a process is created for it, but when the user leaves the app, that process does not quit. The system keeps the process cached, so if the user later returns to the app, the process is reused for faster app switching. Switching Apps
  • 21.  If your app has a cached process and it retains memory that it currently does not need, then your app even while the user is not using it is affecting the system's overall performance.  So, as the system runs low on memory, it may kill processes in the LRU cache beginning with the process least recently used, but also giving some consideration toward which processes are most memory intensive. Switching Apps
  • 22. Process Management A process is a program in execution. A process needs certain resources, including CPU time, memory, files, and I/O devices, to accomplish its task.
  • 23. Process  When an application component starts and the application doesn’t have any other components running, the Android system starts a new Linux process for the application with a single thread of execution.  By default all components of the same application run in the same process and thread(main() thread).
  • 24. Foreground Process An acivitiy which is interacting with user. When an activity calls methods like onstart(), onresume(). When a service is executing any of the methods like onCreate(), onStart(), onDestroy(). Background Process When an acivity running method like onStop(). i.e currently user is not interacting with that activity. System maintains LRU list of background process. Whenever a process decided to kill, it stores the state of activity. So whenever next user wants that activity, we can restore the previous state of activity. Visible Process An acivitiy which is not interacting with user. But it is still visible to user, when an acivity running method like onPause(). When a service is interacting with visible acitvity. Service Process When a service is started using startService(). Eg: playing music in background, downloading file from internet. Empty Process When a process does not have any active component. Caching of empty process inside memory, reduces relaunching of applicaiton once again if user wants that applicaiton in future. Process Life Cycle in Android
  • 25. COMPARISON OF MM BETWEEN ANDROID AND AN OTHER OS (WINDOWS) Android Windows To stress the memory management of the Android, an app creates multiple foreground activities to allocate memory resources. Windows supports virtual memory and can run more programs than there is RAM to hold. High memory and CPU usage. Low memory and CPU usage. Android is an open source platform, meaning that the operating system is available for modification by manufacturers to suit their respective needs and phones. Microsoft Windows is closed-sourced, meaning that it is owned and managed by Microsoft and developers do not have direct access to the operating system programming code. The Android system does not allow the machine to be overcommitted and will terminate idle apps to free memory. In Windows, the main memory is saturated, the virtual memory system starts to thrash and performance is greatly degraded. The programs will run, but very slowly. The library is divided in to two components: Android Runtime and Android Library. Android Runtime is consisted of a Java Core Library and Dalvik Virtual Machine. The core operating system (OS) services consist of the kernel and other features. Core OS services enable low-level tasks, such as process, thread, and memory management. Basic device drivers are also part of the Core OS services. Supported CPU architectures: ARM, x86, MIPS and the 64-bit variants of all three. Supported CPU architecture: ARM
  • 26. SUMMARY  Android is based on a Linux kernel that uses APIs to give access to system calls.  Android uses its own virtual machine called DalvikVM to ensure that multiple processes can run at the same time.  The memory management in Android is based on the priority of the processes that are currently running.  Processes are killed following this priority hierarchy to maintain overall memory management
  • 28. Thanks Everyone for Listening If you have any Questions, feel free to ask…