maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   MeeGo / Harmattan (https://talk.maemo.org/forumdisplay.php?f=45)
-   -   How to free swap memory without rebooting? (https://talk.maemo.org/showthread.php?t=89538)

Hacker 2013-03-21 09:31

How to free swap memory without rebooting?
 
My N9 is fastest in every way when swap memory usage is lowest. Emails swipe faster, homescreens swipe faster, and I think that swap-related slowdown is one of the primary reasons N9 owners are rebooting all of the time--because rebooting resets the swap memory.

I have seen other threads that discuss complex (and admittedly risky) ways to add swap capacity to our N9s, but I have a much more simple question:

How can we reset the swap memory as if we had rebooted without actually rebooting? After looking and searching I have yet to find an answer. I imagine that there must be a command that could be put in Profilematic or simply entered from time to time that would do the job, but what is it?

This could be a game-changer for many users, since clean swap positively impacts my N9's speed performance as much as FasterN9 and light overclocking.

Thanks.

juiceme 2013-03-21 10:00

Re: How to free swap memory without rebooting?
 
Well, I don't use OC, I don't use FasterN9, and still I find the performace good all the time regardless of uptimes...
(well it's only 7 days now because I did some boot stuff back then... but generally I only boot my device when I need to change to different kernel/OS...)

I do not think you need to boot your devices regularily to have good performance. If that's required, then you have misbehaving applications or you have yourself done some tuning of the device that has turned sour. :)

pichlo 2013-03-21 10:23

Re: How to free swap memory without rebooting?
 
Quote:

Originally Posted by Hacker (Post 1330449)
My N9 is fastest in every way when swap memory usage is lowest. Emails swipe faster, homescreens swipe faster, and I think that swap-related slowdown is one of the primary reasons N9 owners are rebooting all of the time--because rebooting resets the swap memory.

I thought the whole idea of swapping is to put the less used memory blocks out of the way but have them ready when needed. Resetting the swap would mean that the next time the memory block is needed, it will have to be reinitialized again which is slower than fetching it from the swap. It is true that the swap space may become fragmented in which case a reset may help a little but you will get a better performance boost by closing applications to reduce the absolute memory usage.

Quote:

How can we reset the swap memory as if we had rebooted without actually rebooting? After looking and searching I have yet to find an answer.
Have you found this?

http://talk.maemo.org/showthread.php?t=84007

You can reset the swap by running (as root)
Code:

swapoff -a
swapon -a

I won't recommend it though. I don't have an N9, but on my N900 this takes a LONG time (minutes) and results in some background tasks forcibly closed as they can't allocate memory while the swap is off.

A better solution would be having TWO swap spaces and from time to time swap (no pun intended) between them. This has been discussed a number of times. See e.g.

http://talk.maemo.org/showthread.php?t=42357
http://talk.maemo.org/showthread.php?t=84296
http://talk.maemo.org/showthread.php?t=86752

...and many others. Some of them discuss the N900 but the solution is actually the same for the N9.

Mikkosssss 2013-03-21 10:50

Re: How to free swap memory without rebooting?
 
I am not sure but is this what you are looking for?

http://store.ovi.com/content/258450?...e=search&pos=1

Lirion 2013-03-21 14:21

Re: How to free swap memory without rebooting?
 
Maybe Dropcache http://store.ovi.com/content/258450 help you out:
(dropcache and inception required)

Code:

terminal command:
aegis-exec /opt/dropcache-mdn/bin/dropcache.sh --3

The linux kernel has it's own algorithm to do this ... so i think it isn't a good idea to periodically force a swap flush either

Hacker 2013-03-21 16:15

Re: How to free swap memory without rebooting?
 
Thanks for the responses! I have read and researched what everyone has said and here's some feedback.

Quote:

Originally Posted by juiceme (Post 1330451)
Well, I don't use OC, I don't use FasterN9, and still I find the performace good all the time regardless of uptimes...
(well it's only 7 days now because I did some boot stuff back then... but generally I only boot my device when I need to change to different kernel/OS...)

I do not think you need to boot your devices regularily to have good performance. If that's required, then you have misbehaving applications or you have yourself done some tuning of the device that has turned sour. :)

Hmmm, given the number of users who use FasterN9, overclocking, etc., slow performance is an issue for many of us! Maybe you have an exceptional N9 or you have different expectations. :-) The problem is not misbehaving apps (I used top command and Conky to check); but rather it seems to be that swap memory is not being freed up even after the related apps are closed, so you eventually use more and more of the available swap memory, causing the N9 to slow down more and more.

The swap-related slowdown issue is discussed in this thread: http://talk.maemo.org/showthread.php?t=84007

I started this thread in hopes that an answer could be found to the swap-reset question. Once we have an answer, It can be merged in a solution thread.

Quote:

Originally Posted by pichlo (Post 1330460)
I thought the whole idea of swapping is to put the less used memory blocks out of the way but have them ready when needed. Resetting the swap would mean that the next time the memory block is needed, it will have to be reinitialized again which is slower than fetching it from the swap. It is true that the swap space may become fragmented in which case a reset may help a little but you will get a better performance boost by closing applications to reduce the absolute memory usage.

Have you found this?

http://talk.maemo.org/showthread.php?t=84007

Yes, I have found that thread, and while your theory seems plausible, it clearly is not working out in real life because several users, including users in the thread that you quote, are having the same problem with swap-related issues! ;-) If the memory were behaving as expected and not causing slowdown, I suppose most of these types of threads would not exist. The problem, I think, is as I stated above: that even closing programs that caused the swap memory to be used does not free swap mem., so it is inevitably exhausted and leads to slower and slower performance.

Quote:

Originally Posted by pichlo (Post 1330460)
You can reset the swap by running (as root)
Code:

swapoff -a
swapon -a

I won't recommend it though. I don't have an N9, but on my N900 this takes a LONG time (minutes) and results in some background tasks forcibly closed as they can't allocate memory while the swap is off.

This approach was discussed in the thread you quote and did not work. :-( Has anyone with an N9 used this approach successfully? I will run a confirmation study when I have a chance.

And thanks for the two swap spaces ideas and research threads. I'll check them out, but am still looking for a workable, easy swap reset approach that avoids reboot.

Mikkosssss and Lirion, I have tried Dropcache, but as discussed in the thread discussed above, it does not seem to solve the problem of freeing swap memory (though it is very useful in tracking the problem as it shows the amount of free swap memory).

Thanks again, everyone.

TMavica 2013-03-21 16:17

Re: How to free swap memory without rebooting?
 
Swap memory cant be free up except booting, only way is to add more swap memory from 255 to 412

Hacker 2013-03-21 16:29

Quote:

Originally Posted by TMavica (Post 1330551)
Swap memory cant be free up except booting, only way is to add more swap memory from 255 to 412

Why? This seems so strange . . . Please help me understand. Is it a bug?

I saw your earlier post, so any insight would be much appreciated.

TMavica 2013-03-21 16:35

Re: How to free swap memory without rebooting?
 
Sorry I dont know why, just know many developer said CANT..I dont know the reason and the meaning, just I know is cant

pichlo 2013-03-21 19:36

Re: How to free swap memory without rebooting?
 
Quote:

Originally Posted by Hacker (Post 1330554)
Quote:

Originally Posted by TMavica (Post 1330551)
Swap memory cant be free up except booting, only way is to add more swap memory from 255 to 412

Why? This seems so strange . . . Please help me understand. Is it a bug?

Look at these figures:
Code:

N900:~# free
            total        used        free      shared      buffers
Mem:        235252      232012        3240            0        1784
-/+ buffers:            230228        5024
Swap:      786424        71540      714884

Of course they will be different on your N9 or even on the next guy's N900, but the idea is the same. The total used memory (main + swap) is higher than the amount of available main memory. Which means some pages have to be swapped. The only way to get around this is by increasing the amount of main memory, which is clearly not possible.

One way of reducing the impact of swapping is spreading the bandwidth, such as one swap partition in the device and one on the SD card, as discussed in those threads that I linked in my first reply.

EDIT: I am actually a bit surprised how much main memory is used before swapping occurs (or how little main memory is left free). My gut feeling would be to strive for at least 20% slack, which would mean even more swap usage. Obviously the Hildon programmers knew better.


All times are GMT. The time now is 20:15.

vBulletin® Version 3.8.8