Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android virtual memory and paging [closed]

Can anyone elaborate or provide a link to android memory management. I am confused about Android virtual memory scheme. How is paging done in Android? Without a hard disk, how do they do it? Do they have caching?

like image 806
agent.smith Avatar asked Apr 13 '11 19:04

agent.smith


2 Answers

Here are some links about memory management on android

A detailed post http://mobworld.wordpress.com/2010/07/05/memory-management-in-android/

And a nice blog post for memory analysis http://android-developers.blogspot.com/2011/03/memory-analysis-for-android.html

How to avoid memory leaks http://android-developers.blogspot.co.uk/2009/01/avoiding-memory-leaks.html

like image 112
Yekmer Simsek Avatar answered Sep 28 '22 01:09

Yekmer Simsek


The linux kernel and the jvm should be treated as apples and oranges. Confusing the two can be disastrous.

For example, the linux kernel's virtual memory is essentially a swap file, and does not set limits on individual process size, which results in "thrashing" or endless swapping when the file is full.

In stark contrast, the jvm (which is just another linux process) sets a common maximum size for its applications (eg 256MB). Android apps generally run in their own jvms, preventing any given jvm from "thrashing". Rather the GC will throw an OOM and exit.

Android will further kill off apps (jvms containing tasks that are groups of activity threads) when running out of kernel virtual memory, and restart them later if required. It can still freeze up (thrash), but not as often as, for eg. an unattended linux database or web server.

The solution for a thrashing (frozen) android is exactly the same as a thrashing linux server. Bounce (cycle the power). Because it is a linux server.

It is somewhat profound to consider that Android has given the world millions of fully connected yet mostly idle pervasive linux servers that can host endless swarms of multithreaded processes (jvms are only one type).

It has the bones of the ultimate super computer, dwarfing even the most elaborate data centre.

That is not even mentioning that most androids have parallel processors (GPUs) that are 100s of times faster than their CPUs, again just sitting idle. Except for a few gamers who know how to fire them up.

Just intended as an overview, there are already excellent links on this thread.

like image 31
Dominic Cerisano Avatar answered Sep 28 '22 02:09

Dominic Cerisano