Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

After opening certain amount of pages in Dolphin Browser Mini (and I think Dolphin HD), the browser dismesses pages from memory as described here: Can I make the browser stop autmatically refreshing pages that haven't been displayed for a while?

The page includes a solution, which is using Swapper 2. Can anyone please explain how it works (not technically but the general idea) / what is it's limitations?

I was thinking of getting a 2GB tablet, since I thought it would be necessary for "multitasking", but this solution seems to work flawlessly for this problem and 2GB of RAM could be totally unnecessary, and hence the question.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Off in the world of real computers, with very fast memory and orders of magnitude slower storage--hard disks--there is the concept of virtual memory. Basically, each application gets what seems like a very large amount of memory, an address space. Behind the scenes, this address space is broken up into pages that are transfered between real, fast, memory and a part of the hard disk called swap space (i.e. slow memory) by the operating system and as needed. In Linux, this swap space can be one or more specially formatted partitions and/or one or more files, or swap files. The operating system is smart enough to keep track of where it's storing what. It also ensures that before a program tries to read/write from a place in memory, that the page being accessed is first moved to real memory.

For example, if you're using your word processor and open 10,000 documents, exhausting main memory, some of the less recently accessed documents may be transfered the swap space to give way for the ones you just opened. If you switch over to your browser, perhaps all of the memory used by the word processor will be shunted to the swap, replaced by the working-state of the browser.

Again, this is done automatically by the operating system, with no real involvement from programs. According to your programs, they're running on a machine with a very large amount of memory. According to the user, when this swapping occurs, there will be brief delays as the operating system moves data between the two types of memory. Back in the Windows 95 days, it was pretty clear when the swapping was occurring as the hard disk light would be pretty much solid for a few seconds.

So, fast forward to phones. On a phone running Android, there is usually no hard disk. Instead, you have main memory--RAM, or that fast memory mentioned above--and some form of non-volatile storage. It turns out that type of memory is slower than RAM, but not nearly as slow as a hard disk. Although it would be tempting to use some or all of this non-volatile storage as swap space, I suspect manufacturers and Google, observed that one property of this non-volatile storage is that it degrades with repeated writes, and so opted not to use it. This means that instead of having seemingly limitless memory, activities on Android only have access to RAM. When the Android framework tries to start an activity and the operating system says sorry, out of memory, Android responds by killing activities until it has reclaimed enough memory. This is why you notice Dolphin Browser actually reloading pages when you switch from and then back to it: Whatever you switched to tried to use so much memory that Android had to start killing activities.

So, Swapper. What swapper does is dig into the operating system and re-enable virtual memory by creating a swap file on your SD card and telling the OS about it. The OS then makes all programs (including the Android framework) feel that they each have a lot of memory, and handles moving data between real memory and the swap file. This is why Dolphin doesn't get killed as frequently with Swapper enabled.

As the Swapper page on Google Play explains, this could have a detrimental effect on whatever non-volatile memory the swap file is placed on. If you're using an SD card, when you start getting write/read errors, you can just swap it out. If you're using a phone with built-in non-volatile memory, it's a different story. I'm not 100% sure what sort of impact repeated writes has to this sort of memory, but it's a risk you should be aware of.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.