I
I
IDOL12342013-12-11 03:26:23
Android
IDOL1234, 2013-12-11 03:26:23

Memory free management in Android. Using swap'a and so on?

Situation:
I have a phone with 850 MB of RAM, of which, after updating to Android 4.3, ~ 350 MB are available to me.
When I open, for example, 3 habr pages in firefox, all other applications are closed, including ICQ and the player, which is not very pleasant.
I want to force android to save data that does not fit in RAM to a swap file on a flash drive. I know it has to do with lags and "flash killing" as they like to write on the forums, but in my opinion, permanent data loss (that's how I view closing the browser with tabs loaded before entering the subway, where there is no connection) is much worse than this. I will repeat especially for those who will dissuade me now:I am not at all satisfied with the current situation, I have already spent a lot of time, I will go to the end.
What has been done:
Installed Cyanogenmod 10.2, made a full backup. Downloaded sources, built a working (hehe) kernel with swap support. A 1 GB file was created (so as not to run 2 times :) on a removable SD card. A strange bug has been found: mkswap, launched from a terminal emulator, always sets the area size to no more than 1020 bytes. Through ADB everything works fine. A typical activation situation:
b6ab0ba72d8c.png
We launch an impudent red face:
523c96f130d6.png
We launch a gluttonous toy: We
8d6ae3459a65.png
close it and we see that Firefox has been closed.
What am I doing wrong?
Where in the source code can I find the mechanism that controls the allocation of memory, if this is not a configuration error?
Are there any global limits on the amount of virtual memory that I could skip when collecting cyanogen?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
Y
Yuri Yarosh, 2013-12-11
@d00mko

The swap file is often disabled in the kernel on build... but that's not your case.
You need to configure the swapping parameters - there are scripts that set the vfs_cache_pressure and vm_swappiness kernel parameters.
They can be set manually via sysctl and in the /etc/sysctl.conf file.
There is more like this

B
Boleg2, 2013-12-11
@Boleg2

Just by the way - in the morning I was leafing through an article in the latest issue of Hacker on the topic of editing the mechanism for organizing RAM built into Android. Maybe it will help? :)

M
mik_os, 2013-12-13
@mik_os

Look at this line and here at this function. By default (24*2/3 = 16) the system allows 24-16=8 background processes, and as soon as the limit is reached, background processes will be cached and killed. A swap with this amount of memory is meaningless. What the free command outputs has nothing to do with the true state of affairs in android, the system allocates almost all the memory for itself, and manages it itself (gives it to applications at startup).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question