![]() |
Re: How to free swap memory without rebooting?
I appreciate the effort, but I don't think that I am being clear enough, so please let me try to restate the problem.
(1) We all agree that when you reboot the N9, there is 255 MB of swap available out of a total swap size of 255 MB. In short, 100% of the swap memory is available immediately after reboot. (2) I think we all agree that after using the device, the swap memory begins to be consumed, so after a bunch of multitasking, use of heavy apps, etc., the swap memory will drop to something like 200MB out of 255MB total. After more use, it may drop to 130 MB out of 255MB total. And ultimately can reach 0MB out of 255MB total. (3) On my device, shutting down the heavy apps, multitasking windows, etc. does NOT restore the swap capacity, so the available swap memory tends only to go down. (4) I have noticed that slowdown both within apps like Fenix and while switching between the three homescreens, and in general other usage, is noticeable and irritating. The slowdown I experience is directly proportional to the degree that swap memory is utilized. Performance slows early on, though it is hardly noticeable, but then gets progressively worse until it absolutely cripples the device. (5) MY QUESTION. Yes, we all know that rebooting the device will get us back to a snappy 255MB out of 255MB of swap available. BUT, how can this exact result be obtained without rebooting the device??? Something like a swap memory refresh script is what I'm looking for. Can you dig it? :) |
Re: How to free swap memory without rebooting?
Don't have any other answer to your query except what all other said i.e. No. Till now haven't heard of any such possible solution or script but that doesn't mean its impossible. That being said you can definitely increase your swap memory without making any changes to your main memory and it is well explained here
http://talk.maemo.org/showpost.php?p...02&postcount=4 which means It will free the 256MB of RAM reserved as Swap and instead use new mtd partition and create new swap memory of 420+MB Currently 1GB RAM is used as 768 MB RAM and 256MB as Swap later it will be used as 1GB RAM + 420MB of SWAP (additional) which means more RAM and more SWAP for your mobile :) Steps are given on this post http://talk.maemo.org/showpost.php?p...3&postcount=51 If you find any issue just PM me. I can explain in detail ;) Cheers |
Re: How to free swap memory without rebooting?
Quote:
Quote:
Quote:
If what you say is this indeed the case then I would expect the available RAM to go drastically down as well. Yes, it is theoretically possible that the swap apace is completely full while the RAM is not. I would expect that to happen if a memory hungry background task has not been used for a long time. Let's call it task X. Other tasks have started, allocated some memory, the kernel had to resort to pushing some memory blocks already in RAM to swap. If task X has not used its memory for a while (and forgot to free it), then after a while it might find all its memory swapped out. When other tasks terminate, they release their memory but task X's memory is not moved from swap back to RAM as it is not needed (yet). This is however a very hypothetical situation that is very easily verified. To give us a better picture, could you please post the result of: Code:
free Code:
top (After starting top, press 'm' to sort the processes by memory usage.) |
In the interest of science, here you are:
BusyBox v1.20.0.git (MeeGo 3:1.20-0.2+0m8) built-in shell (ash) Enter 'help' for a list of built-in commands. ~ $ free total used free shared buffers Mem: 1008648 967212 41436 0 27132 -/+ buffers: 940080 68568 Swap: 262136 54776 207360 ~ $ And here is the top output: Mem: 967620K used, 41028K free, 0K shrd, 27724K buff, 248328K cached Thanks for your interest. Just to make sure, though, I'm really looking for an answer to paragraph (5) in the post above, which should be the same for all N9s, without regard for any specific memory data. :) |
Re: How to free swap memory without rebooting?
Your 'free' output looks OK. Swap is barely used. I assume you are not experiencing any problems now, are you?
A more interesting of the 'top' output would be the following few lines, like this: Code:
Mem: 229072K used, 6180K free, 0K shrd, 43144K buff, 46060K cached |
Quote:
Thanks! I like a good mystery/investigation . . . |
Re: How to free swap memory without rebooting?
Quote:
The kernel may well decide to use swap during boot, but this is not likely. Quote:
Quote:
Imagine (just hypothetically) a music player tells pulseaudio to allocate a chunk of 4MB to buffer music (this is clearly false, but only a made-up example) and then exists without telling pulseaudio that it doesn't need the buffer anymore. The memory used by the player is freed, but those 4MB are still there, allocated (reserved) and basically orphaned forever. Quote:
Quote:
You could try reducing the swappiness, but this will just make your N9 use more RAM. You could also try reducing the block/inode cache. This will get you more free memory at the expense of everything being slower. Basically, the only way to not leak memory is by using programs that don't leak memory. Given the unfortunately "common wisdom" that you are supposed to reboot every couple of hours/days, most programmers don't feel the need to do things properly, thus reinforcing that common wisdom. |
Reinob, I greatly appreciate your response and am thankful for all of the information and help you and others have contributed to this thread.
I think that the middleware idea is the likely issue, with the occasional misbehaving program also being another possible complication. I suppose that reboot is not the worst thing in the world, and if that's the only way to get things fully cleared, then I'll live. :) I still find it strange that things are this way, but c'est la vie avec N9. |
Re: How to free swap memory without rebooting?
But Hacker, please continue investigating this :)
I would like to see what are the programs that are hogging memory on your device, so after few days when it starts swapping a lot, use "top" to see who is the culprit. I assume then just killing&restarting that program you will get your memory back... |
Re: How to free swap memory without rebooting?
Quote:
If so, I've read somewhere (maybe not even applicable anymore) that anonymous memory (backed by swap, not by file, e.g. malloc()'d memory) cannot be reclaimed unless it can be moved to swap (?). Meaning if your swap is too small to even hold a copy of the RAM, then you may actually have memory blocks which *could* be freed which are not been free'd because of lack of swap (???). Besides, it may be that many programs overcommit memory. When a program "reserves" a chunk of memory, that memory is reserved from swap. The memory is only really allocated when it's used. Meaning, if you have little swap (and the N9 has too little), there may be programs which cannot reserve memory (even if it's available), only because of lack of sufficient swap. The only advice I can give is: 1. Increase your swap (if partitioning is a problem with the N9, just make a swap file). 2. Decrease your swappiness (e.g. echo 20 > /proc/sys/vm/swappiness). 3. Increase VFS cache pressure (e.g. echo 200 > /proc/sys/vm/vfs_cache_pressure). This way cache is reclaimed when necessary (instead of swapping out programs). Other things that could help would be e.g. reducing M_MMAP_THRESHOLD and/or M_TRIM_THRESHOLD (at least for long-running programs). But I don't know what the default values are on the N9 (nor on the N900 for that matter). |
All times are GMT. The time now is 14:25. |
vBulletin® Version 3.8.8