0% found this document useful (0 votes)
70 views2 pages

Process Management

Uploaded by

Anindita Mishi
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)
70 views2 pages

Process Management

Uploaded by

Anindita Mishi
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/ 2

1.

Process Importance Hierarchy


Processes in Android are prioritized based on their role in the system:

Foreground Processes: These are actively interacting with the user, such as an app being used. They
have the highest priority and require the most system resources.
Visible Processes: These are processes visible to the user but not actively in use. For example, an app
on-screen but not actively interacted with. They need significant resources to maintain a smooth
experience.
Service Processes: These run in the background for tasks like syncing data or notifications. They have a
medium priority and do not directly interact with the user.
Background Processes: These are idle processes performing minimal tasks. They can be terminated if
the system needs resources.
Empty Processes: These have no active functionality and are kept in memory only to speed up app
relaunches. They are the first to be terminated to free resources.

2. Activity Lifecycle Overview


The activity lifecycle represents the stages an Android activity (screen) goes through:

onCreate(): Initializes the user interface and sets up data.


onStart(): Makes the activity visible to the user.
onResume(): Starts user interaction.
onPause(): Pauses interactions and releases resources (e.g., pausing music playback).
onStop(): Cleans up resources as the activity is no longer visible.
onDestroy(): Performs final cleanup before the activity is terminated.
These lifecycle stages ensure resources are efficiently managed during activity transitions.

3. Inter-Process Communication (IPC)


Android provides several IPC mechanisms for communication between processes:

AIDL (Android Interface Definition Language): Best for two-way communication with complex data. It is
secure but complex to implement, involving interface definitions and handling threads.
Messenger: Simpler than AIDL and supports two-way communication. It is ideal for basic tasks but limited
to handling one request at a time.
Intent: The simplest IPC method. It is secure but supports only one-way communication, making it
unsuitable for ongoing interactions.

4. Background Task Management


This section covers how Android handles background tasks to ensure efficient resource usage:

Services:
Started Services: Run until explicitly stopped (e.g., downloading files).
Bound Services: Provide interfaces for communication with other components (e.g., syncing data).
Broadcast Receivers: Respond to system-wide events like network changes but are not suitable for heavy
tasks.
JobScheduler: Manages tasks under specific conditions (e.g., Wi-Fi connectivity) and consolidates tasks
to save battery life.
WorkManager: Schedules reliable tasks that persist across app or device restarts. It supports one-time or
periodic tasks.
AlarmManager: Schedules tasks at specific times but is less efficient for frequent tasks.
Foreground Services: Handle ongoing tasks critical to user experience, requiring a persistent notification
to prevent termination.

5. Process Reuse and Optimization


Android employs strategies to reuse and optimize processes:
Process Reuse: Cached processes (idle but still in memory) are reused instead of creating new ones.
This reduces overhead and speeds up app relaunches.
Memory Optimization: Techniques include:
Garbage collection to free unused memory.
Object pooling and optimized image loading.
Avoiding memory leaks by properly releasing resources.
CPU Optimization: Heavy tasks are moved to background threads to avoid app freezing, using tools like
AsyncTask or WorkManager.
Battery Optimization: Features like Doze Mode and App Standby reduce background activity to save
battery life.

6. Android Process Lifecycle


This section emphasizes the importance of process reuse in Android:

Cached processes enable faster app relaunches and switching, improving multitasking.
Tools like onTrimMemory(), Doze Mode, and App Standby reduce unnecessary resource usage,
enhancing performance and battery life.

7. Security and Isolation in Android Process Management


Android ensures secure and isolated process management through:

Process Isolation: Unique user IDs (UIDs) prevent unauthorized data sharing.
Sandboxing: Restricts app interactions to maintain security.
Permission-Based Access: Apps access data only with user consent, preventing malware and protecting
system integrity.

8. System Tools for Process Monitoring


Android provides several tools for developers to monitor and optimize processes:

Android Debug Bridge (ADB): Command-line tool for managing processes.


Activity Manager (AM): Tracks app activities and processes.
Android Studio Profiler: Offers real-time insights into CPU, memory, and network usage.
Logcat: Monitors system logs for debugging.
Battery Historian: Analyzes battery usage and identifies resource-intensive processes.

9. Low Memory Killer (LMK) in Process Management


The LMK system in Android manages low-memory situations by:

Monitoring memory usage.


Detecting thresholds that trigger action.
Terminating low-priority processes.
Adjusting performance and stabilizing the system. Processes are prioritized from active (highest priority)
to empty (lowest priority) to determine which ones are terminated first.

10. Key Components of App Switching


Android manages app switching efficiently through:

Context Switching: Saves and restores app states during transitions, ensuring seamless multitasking.
Memory Allocation: Assigns or reclaims RAM based on app priority.
Demand Paging: Loads only necessary parts of an app to optimize memory.
App Swap-In: Restores app states when switching back to previously closed or backgrounded apps.

You might also like