0% found this document useful (0 votes)
396 views

Case Study About Android and IOS Final Project Report

This project report summarizes a case study on the Android and iOS mobile operating systems. It was submitted by Ezatullah Amin and Leom Socheanet under the guidance of Dr. Jasraj Meena. The report provides an overview of popular mobile operating systems, describes key features of iOS and Android, and discusses their architecture and development. It aims to compare the two operating systems for a final evaluation course on operating systems.

Uploaded by

Socheanith Loem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
396 views

Case Study About Android and IOS Final Project Report

This project report summarizes a case study on the Android and iOS mobile operating systems. It was submitted by Ezatullah Amin and Leom Socheanet under the guidance of Dr. Jasraj Meena. The report provides an overview of popular mobile operating systems, describes key features of iOS and Android, and discusses their architecture and development. It aims to compare the two operating systems for a final evaluation course on operating systems.

Uploaded by

Socheanith Loem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

Project Report

On

“Case Study on Android and IOS”


Submitted for the Final Evaluation of the
Operating System 4th-Semester

Submitted By

Ezatullah Amin (2K19/IT/047)

&

Leom Socheanet (2K19/IT/073)

Under the Guidance of

Dr. Jasraj Meena


Acknowledgement
We have taken efforts in this projects. However, it would not have been
possible without the kind support and help of many individual. We would
like to extend our sincere thanks to all of them.

We are highly indebted to ‘Dr. Jasraj Meena’ for their guidance and
constant supervision as well as for providing necessary information
regarding the project and also for their support in completing the project.

We would like to express our gratitude towards our parents and members of
DTU for their co-operation and encouragement which help us in the
completion of this project.

My thanks and appreciations also go to my friend “Ezatullah Amin” in


developing the project and people who have willingly helped us out with
their abilities.
Table of content
1.1What is mobile operating system?

2.1Popular platforms of the Mobile OS


1.2.1 Android OS
2.2.1 Bada (Samsung Electronics)
3.2.1 BlackBerry OS
4.2.1 iPhone OS / ios
5.2.1 Symbian OS
6.2.1 Windows Mobile OS
7.2.1 Harmony OS
8.2.1 Palm OS
9.2.1 WebOS (Palm/HP)
3.1What is iOS?
4.1Features of IOS Platform

5.1History

6.1Architecture of iOS

1.6.1Core OS Layer
2.6.1 Core Services Layer
3.6.1Address book framework
4.6.1Cloud Kit framework
5.6.1Core data Framework
6.6.1Core Foundation framework
7.6.1Core Location framework
8.6.1Core Motion Framework
9.6.1Foundation Framework
10.6.1Healthkit framework
11.6.1Homekit framework
12.6.1Social framework
13.6.1StoreKit framework

7.1Technologies used by Ios

8.1User Interface

1.8.1 UIKit

2.8.1Core Graphics

3.8.1 Core Animation

9.1Games

1.9.1 GameKit

2.9.1 SpriteKit

3.9.1 OpenGL ES

4.9.1 Game Controller

10.1Data

1.10.1Core Data

2.10.1 Foundation

11.1Memory management in iOS?

12.1Memory Management Issues

13.1Memory Management Rules

14.1Handling Memory in ARC

15.1Memory Management Tools

1.2What is Android?

2.2Why Android?

3.2Features of Android
1.3.2Beautiful UI
2.3.2Connectivity
3.3.2Storage
4.3.2Media support
5.3.2Messaging
6.3.2Web browser
7.3.2Multi-touch
8.3.2Multi-tasking
9.3.2Resizable widgets
10.3.2Multi-Language
11.3.2GCM
12.3.2Wi-Fi Direct
13.3.2Android Beam

4.2Android Applications

5.2Categories of Android applications

6.2History of Android
7.2Android – Architecture

8.2Linux kernel

9.2Libraries

10.2Android Libraries
1.10.2android.app
2.10.2android.content
3.10.2android.database
4.10.2android.opengl
5.10.2android.os
6.10.2android.text
7.10.2android.view
8.10.2android.widget
9.10.2android.webkit
11.2Android Runtime
12.2Android – Services
13.2Started
14.2Bound
15.2Android - Content Providers
16.2Android – Fragments
17.2Overview of memory management

18.2Garbage collection

19.2Share memory
20.2References
1.1What is mobile operating system?
Every computer or mobile device has an operating system (OS) installed on
it. Windows, OS X (now macOS), Unix, Linux, Android, and iOS are all
operating systems.

Whether it's a laptop, desktop computer, smartphone, tablet, or smart watch,


operating systems serve as graphical software overlays for controlling the
device's internal hardware. The difference between OS reflect the different
needs and purposes of the device. Mobile operating systems
like Android and iOS, for example, are specifically designed to
power smartphones, tablets, and wearables.

Most mobile OS present as a graphical display of buttons, icons, windows,


and tiles that you can touch or interact with to perform various tasks. This
visual architecture is the backbone of the operating system. Without the OS,
the device would be a series of command prompts and inscrutable computer
code.

The mobile operating system manages the hardware and makes it possible
for smartphones, tablets, and wearables to run apps and other programs in a
user-friendly way. A mobile OS also manages mobile multimedia functions,
mobile and internet connectivity, touch screen controls, Bluetooth
connectivity, GPS navigation, cameras, speech recognition, and more. Most
operating systems are not interchangeable. For example, if you have a
Samsung phone, which runs the Android OS, you cannot use it to run Apple
iOS, which is the operating system used to run iPhones, iPads, and iPod
Touches.

2.1Popular platforms of the Mobile OS


1.2.1 Android OS: The Android operating system is the most
popular operating system today. It is a mobile OS based on the Linux
Kernel and open-source software. The android operating system was
developed by Google. The first Android device was launched in 2008.

2.2.1 Bada (Samsung Electronics): Bada is a Samsung mobile operating


system that was launched in 2010. The Samsung wave was the first mobile
to use the bada operating system. The bada operating system offers many
mobile features, such as 3-D graphics, application installation, and
multipoint-touch.
3.2.1 BlackBerry OS: The BlackBerry operating system is a mobile
operating system developed by Research in Motion (RIM). This operating
system was designed specifically for BlackBerry handheld devices. This
operating system is beneficial for the corporate users because it provides
synchronization with Microsoft Exchange, Novell GroupWise email, Lotus
Domino, and other business software when used with the BlackBerry
Enterprise Server.

4.2.1 iPhone OS / iOS: The iOS was developed by the Apple Inc. for the
use on its device. The iOS operating system is the most popular operating
system today. It is a very secure operating system. The iOS operating
system is not available for any other mobiles.

5.2.1 Symbian OS: Symbian operating system is a mobile operating system


that provides a high-level of integration with communication. The Symbian
operating system is based on the java language. It combines middleware of
wireless communications and personal information management (PIM)
functionality. The Symbian operating system was developed by Symbian
Ltd in 1998 for the use of mobile phones. Nokia was the first company to
release Symbian OS on its mobile phone at that time.

6.2.1 Windows Mobile OS: The window mobile OS is a mobile operating


system that was developed by Microsoft. It was designed for the pocket PCs
and smart mobiles.

7.2.1 Harmony OS: The harmony operating system is the latest mobile
operating system that was developed by Huawei for the use of its devices. It
is designed primarily for IoT devices.

8.2.1 Palm OS: The palm operating system is a mobile operating system
that was developed by Palm Ltd for use on personal digital assistants
(PADs). It was introduced in 1996. Palm OS is also known as the Garnet
OS.

9.2.1 WebOS (Palm/HP): The WebOS is a mobile operating system that


was developed by Palm. It based on the Linux Kernel. The HP uses this
operating system in its mobile and touchpads.

As we are focusing on iOS and android so let’s now discuss this two
operating system and details:

3.1What is iOS?
IOS stands for iphone operating system. It is a proprietary mobile operating
system of apple for its handheld. It supports Objective-C, C, C++, Swift
programming language. It is based on the Macintosh OS X. iPhone, iPod,
iPad and apple TV all comes with IOS.

4.1Features of IOS Platform


It has following features:

• Multitasking
• Social Media
• iCloud
• In-App purchase
• Game Center
• Notification Center
• Accelerometer
• Gyroscope
• Powerful APIs
• GPS
• High end processor
• Accessibility
• Bluetooth
• Orientations
• Camera integration
• Location services
• Maps
• Email, contacts, web pages and messages etc.

5.1History
iPhone was first release in June, 2007 and on September 5, 2007, Apple
released the iPod Touch which had most of the non-phone abilities of the
iPhone. In June 2010 apple rebranded iPhone OS as iOS. iPad first
generation was released in April 2010 and iPad Mini was released in
November 2012.
To develop iOS application use following steps:

• Register as a developer.

• Design beautiful app interfaces.

• Learn the Objective-C language.

• Develop great apps.

• Learn about the technologies available to you.

• Access the documentation.

• Debug and test your app.

• Ship your app.

6.1Architecture of iOS
Architecture of IOS is a layered architecture. At the uppermost level iOS
works as an intermediary between the underlying hardware and the apps you
make. Apps do not communicate to the underlying hardware directly.
Apps talk with the hardware through a collection of well-defined system
interfaces. These interfaces make it simple to write apps that work
constantly on devices having various hardware abilities.
Lower layers gives the basic services which all application relies on and
higher level layer gives sophisticated graphics and interface related services.
Apple provides most of its system interfaces in special packages called
frameworks. A framework is a directory that holds a dynamic shared library
that is. a files, related resources like as header files, images, and helper apps
required to support that library. Every layer has a set of Framework which
the developer uses to construct the applications.

1.6.1Core OS Layer
The Core OS layer holds the low level features that most other technologies
are built upon.

• Core Bluetooth Framework.


• Accelerate Framework.
• External Accessory Framework.
• Security Services framework.
• Local Authentication framework.

64-Bit support from IOS7 supports the 64-bit app development and enables
the application to run faster.
2.6.1 Core Services Layer Some of the Important Frameworks available in
the core services layers are detailed:

• 3.6.1Address book framework – Gives programmatic access to a


contacts database of user.
• 4.6.1Cloud Kit framework – Gives a medium for moving data between
your app and iCloud.
• 5.6.1Core data Framework – Technology for managing the data model
of a Model View Controller app.

• 6.6.1Core Foundation framework – Interfaces that gives fundamental


data management and service features for iOS apps.

• 7.6.1Core Location framework – Gives location and heading


information to apps.

• 8.6.1Core Motion Framework – Access all motion based data


available on a device. Using this core motion framework Accelerometer
based information can be accessed.

• 9.6.1Foundation Framework – Objective C covering too many of the


features found in the Core Foundation framework

• 10.6.1Healthkit framework – New framework for handling health-


related information of user

• 11.6.1Homekit framework – New framework for talking with and


controlling connected devices in a user’s home.

• 12.6.1Social framework – Simple interface for accessing the user’s


social media accounts.

• 13.6.1StoreKit framework – Gives support for the buying of content


and services from inside your iOS apps, a feature known asIn-App
Purchase.

7.1Technologies used by iOS


IOS provides frameworks that define particular sets of functionality from
gaming and media to security and data management which you can
integrate into your app. UIKit framework is used to design your app’s user
interface and the Foundation framework to incorporate common data
structures and behavior into your code. These are two of the most common
frameworks used in iOS app development.
8.1User Interface
1.8.1 UIKit

Its classes allow you create a touch based user interface. Because all iOS
apps are based on UIKit, you can’t ship an app without this framework. It
gives the infrastructure for drawing to the screen, handling events and
creating common user interface elements. UIKit also arranges a complex
app by organizing the content that’s showed on the screen.

2.8.1Core Graphics

It is a low level, C based framework. It is the workhorse for handling high


quality vector graphics, path based drawing, transformations, images, data
management and more.
The easiest and most efficient way to create graphics in iOS is to use
prerendered images with the standard views and controls of the UIKit
framework. Because UIKit is a higher-level framework which also provides
classes for custom drawing including paths, colors, patterns, gradients,
images, text, and transformations.

3.8.1 Core Animation

Its interfaces are part of the Quartz Core framework. To create higher level
animations and visual effects use Core Animation. UIKit provides
animations that are built on top of the Core Animation technology.
If you require advanced animations further than the capabilities of UIKit,
use Core Animation directly. You can create a hierarchy of layer objects
that you manipulate, rotate, scale, transform. Core Animation’s familiar
view-like abstraction lets you can create dynamic user interfaces without
having to use low-level graphics APIs such as OpenGL ES.

9.1Games
1.9.1 GameKit

This framework provides leaderboards, achievements and other features to


add to your iOS game.

2.9.1 SpriteKit
This framework provides graphics support for animating arbitrary textured
images or sprites. In addition to being a graphics engine, it also contains
physics support to bring objects to life. It is a good option for games and
other apps that need complex animation chains.

3.9.1 OpenGL ES

It is a low level framework that supports hardware accelerated 2D and 3D


drawing. Apple’s implementation of the OpenGL ES standard works
intimately with the device hardware to give high frame rates for full screen,
game-style apps. Because It is a low-level, hardware focused API, it has a
steep learning curve and a significant effect on the overall design of your
app.

4.9.1 Game Controller

This framework makes it simple to search controllers connected to a Mac


or iOS device. When a controller is opened on your device, your game
examines control inputs as part of its normal gameplay. These controllers
give new ways for players to control your game. Apple has designed
specifications for hardware controllers to ensure that all controllers have
consistent sets of control elements that both players and game designers
can rely on.

10.1Data
1.10.1Core Data

It manages an app’s data model. Use it to create model objects which are
known as managed objects. You manage relationships between those
objects and make changes to the data through the framework. It takes
benefit of the built in SQLite technology to save and manage data
competently.

2.10.1 Foundation

This framework defines a set of important base classes. Among other


things this framework contains classes representing basic data types like as
strings and numbers and collection classes for saving other objects.
11.1Memory management in iOS?
Memory management in iOS was initially non-ARC (Automatic Reference
Counting), where we have to retain and release the objects. Now, it
supports ARC and we don't have to retain and release the objects. Xcode
takes care of the job automatically in compile time.

12.1Memory Management Issues


As per Apple documentation, the two major issues in memory management
are
• Freeing or overwriting data that is still in use. It causes memory
corruption and typically results in your application crashing, or worse,
corrupted user data.
• Not freeing data that is no longer in use causes memory leaks. When
allocated memory is not freed even though it is never going to be used
again, it is known as memory leak. Leaks cause your application to
use ever-increasing amounts of memory, which in turn may result in
poor system performance or (in iOS) your application being
terminated.

13.1Memory Management Rules


• We own the objects we create, and we have to subsequently release
them when they are no longer needed.
• Use Retain to gain ownership of an object that you did not create. You
have to release these objects too when they are not needed.
• Don't release the objects that you don't own.

14.1Handling Memory in ARC


You don't need to use release and retain in ARC. So, all the view controller's
objects will be released when the view controller is removed. Similarly, any
object’s sub-objects will be released when they are released. Note that if
other classes have a strong reference to an object of a class, then the whole
class won't be released. So, it is recommended to use weak properties for
delegates.
15.1Memory Management Tools
We can analyze the usage of memory with the help of Xcode tool
instruments. It includes tools such as Activity Monitor, Allocations, Leaks,
Zombies, and so on.

1.2What is Android?

Android is an open source and Linux-based Operating System for mobile


devices such as smartphones and tablet computers. Android was developed
by the Open Handset Alliance, led by Google, and other companies.
Android offers a unified approach to application development for mobile
devices which means developers need only develop for Android, and their
applications should be able to run on different devices powered by Android.
The first beta version of the Android Software Development Kit (SDK) was
released by Google in 2007 where as the first commercial version, Android
1.0, was released in September 2008.
On June 27, 2012, at the Google I/O conference, Google announced the next
Android version, 4.1 Jelly Bean. Jelly Bean is an incremental update, with
the primary aim of improving the user interface, both in terms of
functionality and performance.
The source code for Android is available under free and open source software
licenses. Google publishes most of the code under the Apache License
version 2.0 and the rest, Linux kernel changes, under the GNU General
Public License version 2.

2.2Why Android?

3.2Features of Android
Android is a powerful operating system competing with Apple 4GS and
supports great features. Few of them are listed below
1.3.2Beautiful UI
Android OS basic screen provides a beautiful and intuitive user interface.
2.3.2Connectivity
GSM/EDGE, IDEN, CDMA, EV-DO, UMTS, Bluetooth, Wi-Fi, LTE, NFC
and WiMAX.
3.3.2Storage
SQLite, a lightweight relational database, is used for data storage purposes.
4.3.2Media support
H.263, H.264, MPEG-4 SP, AMR, AMR-WB, AAC, HE-AAC, AAC 5.1,
MP3, MIDI, Ogg Vorbis, WAV, JPEG, PNG, GIF, and BMP.
5.3.2Messaging
SMS and MMS
6.3.2Web browser
Based on the open-source WebKit layout engine, coupled with Chrome's V8
JavaScript engine supporting HTML5 and CSS3.
7.3.2Multi-touch
Android has native support for multi-touch which was initially made
available in handsets such as the HTC Hero.
8.3.2Multi-tasking
User can jump from one task to another and same time various application
can run simultaneously.
9.3.2Resizable widgets
Widgets are resizable, so users can expand them to show more content or
shrink them to save space.
10.3.2Multi-Language
Supports single direction and bi-directional text.
11.3.2GCM
Google Cloud Messaging (GCM) is a service that lets developers send short
message data to their users on Android devices, without needing a
proprietary sync solution.
12.3.2Wi-Fi Direct
A technology that lets apps discover and pair directly, over a high-bandwidth
peer-to-peer connection.
13.3.2Android Beam
A popular NFC-based technology that lets users instantly share, just by
touching two NFC-enabled phones together.

4.2Android Applications
Android applications are usually developed in the Java language using the
Android Software Development Kit.
Once developed, Android applications can be packaged easily and sold out
either through a store such as Google Play, SlideME, Opera Mobile
Store, Mobango, F-droid and the Amazon Appstore.
Android powers hundreds of millions of mobile devices in more than 190
countries around the world. It's the largest installed base of any mobile
platform and growing fast. Every day more than 1 million new Android
devices are activated worldwide.
This project has been written with an aim to teach you how to develop and
package Android application. We will start from environment setup for
Android application programming and then drill down to look into various
aspects of Android applications.

5.2Categories of Android applications


There are many android applications in the market. The top categories are

6.2History of Android
The code names of android ranges from A to N currently, such as Aestro,
Blender, Cupcake, Donut, Eclair, Froyo, Gingerbread, Honeycomb, Ice
Cream Sandwich, Jelly Bean, KitKat, Lollipop and Marshmallow. Let's
understand the android history in a sequence.

7.2Android - Architecture
Android operating system is a stack of software components which is
roughly divided into five sections and four main layers as shown below in
the architecture diagram.
8.2Linux kernel
At the bottom of the layers is Linux - Linux 3.6 with approximately 115
patches. This provides a level of abstraction between the device hardware
and it contains all the essential hardware drivers like camera, keypad, display
etc. Also, the kernel handles all the things that Linux is really good at such
as networking and a vast array of device drivers, which take the pain out of
interfacing to peripheral hardware.

9.2Libraries
On top of Linux kernel there is a set of libraries including open-source Web
browser engine WebKit, well known library libc, SQLite database which is
a useful repository for storage and sharing of application data, libraries to
play and record audio and video, SSL libraries responsible for Internet
security etc.

10.2Android Libraries
This category encompasses those Java-based libraries that are specific to
Android development. Examples of libraries in this category include the
application framework libraries in addition to those that facilitate user
interface building, graphics drawing and database access. A summary of
some key core Android libraries available to the Android developer is as
follows −
• 1.10.2android.app
Provides access to the application model and is the cornerstone of all
Android applications.
• 2.10.2android.content
Facilitates content access, publishing and messaging between
applications and application components.
• 3.10.2android.database
Used to access data published by content providers and includes
SQLite database management classes.
• 4.10.2android.opengl
A Java interface to the OpenGL ES 3D graphics rendering API.
• 5.10.2android.os
Provides applications with access to standard operating system
services including messages, system services and inter-process
communication.
• 6.10.2android.text
Used to render and manipulate text on a device display.
• 7.10.2android.view
The fundamental building blocks of application user interfaces.
• 8.10.2android.widget
A rich collection of pre-built user interface components such as
buttons, labels, list views, layout managers, radio buttons etc.
• 9.10.2android.webkit
A set of classes intended to allow web-browsing capabilities to be
built into applications.
Having covered the Java-based core libraries in the Android runtime, it is
now time to turn our attention to the C/C++ based libraries contained in this
layer of the Android software stack.

11.2Android Runtime
This is the third section of the architecture and available on the second layer
from the bottom. This section provides a key component called Dalvik
Virtual Machine which is a kind of Java Virtual Machine specially designed
and optimized for Android.
The Dalvik VM makes use of Linux core features like memory management
and multi-threading, which is intrinsic in the Java language. The Dalvik VM
enables every Android application to run in its own process, with its own
instance of the Dalvik virtual machine.
The Android runtime also provides a set of core libraries which enable
Android application developers to write Android applications using standard
Java programming language.

12.2Android - Services
A service is a component that runs in the background to perform long-
running operations without needing to interact with the user and it works
even if application is destroyed. A service can essentially take two states
13.2Started
A service is started when an application component, such as an activity, starts
it by calling startService(). Once started, a service can run in the background
indefinitely, even if the component that started it is destroyed.
14.2Bound
A service is bound when an application component binds to it by calling
bindService(). A bound service offers a client server interface that allows
components to interact with the service send requests, get result, and even
do so across processes with interprocess communication (IPC).
A service has life cycle callback methods that you can implement to monitor
changes in the service's state and you can perform work at the appropriate
stage. The following diagram on the left shows the life cycle when the
service is created with startService() and the diagram on the right shows the
life cycle when the service is created with bindService(): (image courtesy :
android.com )

To create an service, you create a Java class that extends the Service base
class or one of its existing subclasses. The Service base class defines various
callback methods and the most important are given below. You don't need to
implement all the callbacks methods. However, it's important that you
understand each one and implement those that ensure your app behaves the
way users expect.

15.2Android - Content Providers


A content provider component supplies data from one application to
others on request. Such requests are handled by the methods of the
Content Resolver class. A content provider can use different ways to
store its data and the data can be stored in a database, in files, or
even over a network.

Content providers let you centralize content in one place and have many
different applications access it as needed. A content provider behaves very
much like a database where you can query it, edit its content, as well as add
or delete content using insert(), update(), delete(), and query() methods. In
most cases this data is stored in an SQlite database.
A content provider is implemented as a subclass of ContentProvider class
and must implement a standard set of APIs that enable other applications to
perform transactions.
public class My Application extends ContentProvider {
}
16.2Android – Fragments

A Fragment is a piece of an activity which enable more modular activity


design. It will not be wrong if we say, a fragment is a kind of sub-activity.

Following are important points about fragment −


• A fragment has its own layout and its own behavior with its own life
cycle callbacks.
• You can add or remove fragments in an activity while the activity is
running.
• You can combine multiple fragments in a single activity to build a
multi-pane UI.
• A fragment can be used in multiple activities.
• Fragment life cycle is closely related to the life cycle of its host activity
which means when the activity is paused, all the fragments available
in the activity will also be stopped.
• A fragment can implement a behaviour that has no user interface
component.
• Fragments were added to the Android API in Honeycomb version of
Android which API version 11.

You create fragments by extending Fragment class and You can insert a
fragment into your activity layout by declaring the fragment in the activity's
layout file, as a <fragment> element.
Prior to fragment introduction, we had a limitation because we can show only
a single activity on the screen at one given point in time. So we were not able
to divide device screen and control different parts separately. But with the
introduction of fragment we got more flexibility and removed the limitation
of having a single activity on the screen at a time. Now we can have a single
activity but each activity can comprise of multiple fragments which will have
their own layout, events and complete life cycle.
Following is a typical example of how two UI modules defined by fragments
can be combined into one activity for a tablet design, but separated for a
handset design.
The application can embed two fragments in Activity A, when running on a
tablet-sized device. However, on a handset-sized screen, there's not enough
room for both fragments, so Activity A includes only the fragment for the
list of articles, and when the user selects an article, it starts Activity B,
which includes the second fragment to read the article.

17.2Overview of memory management


The Android Runtime (ART) and Dalvik virtual machine
use paging and memory-mapping (mmapping) to manage memory. This
means that any memory an app modifies—whether by allocating new
objects or touching mmapped pages—remains resident in RAM and cannot
be paged out. The only way to release memory from an app is to release
object references that the app holds, making the memory available to the
garbage collector. That is with one exception: any files mmapped in without
modification, such as code, can be paged out of RAM if the system wants to
use that memory elsewhere.

18.2Garbage collection
A managed memory environment, like the ART or Dalvik virtual machine,
keeps track of each memory allocation. Once it determines that a piece of
memory is no longer being used by the program, it frees it back to the heap,
without any intervention from the programmer. The mechanism for
reclaiming unused memory within a managed memory environment is
known as 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.

Android’s memory heap is a generational one, meaning that there are


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 an older generation, followed by a permanent
generation.

Each heap generation has its own dedicated upper limit on the amount of
memory that objects there can occupy. Any time a generation starts to fill
up, the system executes a garbage collection event in an attempt to free up
memory. The duration of the garbage collection depends on which
generation of objects it's collecting and how many active objects are in each
generation.

Even though garbage collection can be quite fast, it can still affect your
app's performance. You don’t generally control when a garbage collection
event occurs from within your code. The system has a running set of criteria
for determining when to perform garbage collection. When the criteria are
satisfied, the system stops executing the process and begins garbage
collection. If garbage collection occurs in the middle of an intensive
processing loop like an animation or during music playback, it can increase
processing time. This increase can potentially push code execution in your
app past the recommended 16ms threshold for efficient and smooth frame
rendering.

Additionally, your code flow may perform kinds of work that force garbage
collection events to occur more often or make them last longer-than-normal.
For example, if you allocate multiple objects in the innermost part of a for-
loop during each frame of an alpha blending animation, you might pollute
your memory heap with a lot of objects. In that circumstance, the garbage
collector executes multiple garbage collection events and can degrade the
performance of your app.

19.2Share 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:

• Each app process is forked from an existing process called Zygote. The
Zygote process starts when the system boots and loads common framework
code and resources (such as activity themes). To start a new app process, the
system forks the Zygote process then loads and runs the app's code in the
new process. This approach allows most of the RAM pages allocated for
framework code and resources to be shared across all app processes.
• Most static data is mmapped into a process. This technique allows data to be
shared between processes, and also allows it to be paged out when needed.
Example static data include: Dalvik code (by placing it in a pre-
linked. odex file for direct mmapping), app resources (by designing the
resource table to be a structure that can be mmapped and by aligning the zip
entries of the APK), and traditional project elements like native code
in .so files.
• In many places, Android shares the same dynamic RAM across processes
using explicitly allocated shared memory regions (either with ashmem or
gralloc). For example, window surfaces use shared memory between the app
and screen compositor, and cursor buffers use shared memory between the
content provider and client.
20.2References
What is an Operating System? (https://www.howtogeek.com/361572/what-
is-an-operating-system/)

Android vs iOS: Which Smartphone Platform Is the Best


(https://www.digitaltrends.com/mobile/android-vs-ios/)

How are iOS and Android similar? How are they different?
(https://www.tutorialspoint.com/how-are-ios-and-android)

You might also like