Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why don't most Android devices have swap area as typical OS does?

Does any Android today support swap area which is suppose to boost the performance?

What are the considerations that make most Android devices drop that feature?

like image 865
JackWM Avatar asked Jul 04 '13 21:07

JackWM


People also ask

Does Android use swap space?

On Android, storage isn't used for swap space like it is on other Linux implementations since frequent writing can cause wear on this memory, and shorten the life of the storage medium.

What is swap space in the OS how is it used?

Swap space is a space on a hard disk that is a substitute for physical memory. It is used as virtual memory which contains process memory images. Whenever our computer runs short of physical memory it uses its virtual memory and stores information in memory on disk.

What is swap in Mobile?

A SWAP allows a customer to move phone numbers, plans and services between an active device and an inactive device. It allows the inactive device to become active on the Sprint network after a device is purchased or replaced, see Answer 1089.


3 Answers

Does any Android today support swap area?

Quoting Dianne Hackborn:

To be a little more specific, it does use paging but not swap space. That is, it relies heavily on being able to mmap() files and have the kernel page in data from the file as needed (and drop those pages when not needed). It does not however use swap space for paging out dirty pages.


With some slightly adaptions, swap area can work with Android's default low memory killer together well, right?

I certainly would not assume that.

Does any Android today support swap area which is suppose to boost the performance?

It is not supposed to "boost the performance".

what's the considerations that make Android drop this idea?

First, on-board flash is slow, much slower than the hard drives and SSDs that you are used to on desktops and notebooks. And while the quality of the flash storage used on Android devices today is better than it used to be, it's still not screaming fast. That's why, for example, we have to take special care when doing database I/O, to use transactions, to limit the number if disk write operations.

Second, historically, on-board flash was limited in space. We didn't have enough internal storage for our apps, let alone to dedicate some for swap.


If you wish to discuss this further, please use a more appropriate forum, such as http://android.stackexchange.com, as your question is only tangentially related to software development.

like image 102
CommonsWare Avatar answered Sep 20 '22 22:09

CommonsWare


Android does support swap... Don't forget it's just plain Linux with some UI on it. :)

However the support is dependent on the kernel you are using.. When using a kernel you should know if it supports swap space or not..

If you are good in kernels, then grab the source, enable swap support and compile it. I guarantee that should be fun :p

Personally my kernel supports swap space and I use a 20 MB file to act as a swap file.

like image 38
Miro Markaravanes Avatar answered Sep 19 '22 22:09

Miro Markaravanes


For Android or even iOS to practically support non-kernel swapping, three hurdles must be overcome:

  1. Space Constraints: Due to the usage of flash memory, as opposed to HDD's, space comes at a relative premium
  2. Write Frequency: Flash memory tolerates fewer writes before becoming unreliable (relative to HDD)
  3. Communication Throughput: There is poor throughput between main memory and flash memory on mobile devices
like image 26
Dean P Avatar answered Sep 20 '22 22:09

Dean P