Reply
Thread Tools
Posts: 359 | Thanked: 322 times | Joined on Jun 2010
#11
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?
__________________
Hitting this thanks button will make you smile and feel good ----------------------------------------------------------------->
 
Posts: 152 | Thanked: 70 times | Joined on Aug 2012 @ India
#12
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
 

The Following User Says Thank You to kumary For This Useful Post:
pichlo's Avatar
Posts: 6,450 | Thanked: 20,983 times | Joined on Sep 2012 @ UK
#13
(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.
Actually, there is 100% out of the total virtual memory (RAM + swap) available. I am not sure on exact figures; is it 1 GB RAM + 256 MB swap or 1 GB altogether?

(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.
Again, we are talking about the total virtual memory (RAM + swap) that gets consumed. Swap is just an extension of the RAM, nothing more, nothing less. Memory gets allocated by the OS and applications. When there is not enough memory in the RAM, some pages are swapped out (moved to swap). When the application frees the memory (which happens naturally during its operation and always upon terminating it), it does not matter where the memory block actually is. Swap or RAM, it is made available again.

(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.
That is very strange. Applications and most OS components have no way of telling which memory to use. They just go, "give me some memory" and "here is your memory back, I no longer need it". Only the kernel decides whether a certain memory page should be in RAM or in swap, using a sophisticated algorithm, based mostly the frequency of the access to a particular page. More used pages stay in the RAM, the less used ones go to the slower part of the virtual memory, a.k.a. swap.

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
followed by
Code:
top
Ideally when you experience your swap problems as described.
(After starting top, press 'm' to sort the processes by memory usage.)
 

The Following 2 Users Say Thank You to pichlo For This Useful Post:
Posts: 359 | Thanked: 322 times | Joined on Jun 2010
#14
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.
__________________
Hitting this thanks button will make you smile and feel good ----------------------------------------------------------------->
 

The Following User Says Thank You to Hacker For This Useful Post:
pichlo's Avatar
Posts: 6,450 | Thanked: 20,983 times | Joined on Sep 2012 @ UK
#15
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
CPU:  2.5% usr  5.3% sys  0.0% nic 89.4% idle  2.5% io  0.0% irq  0.0% sirq
Load average: 0.09 0.08 0.07 1/205 4629
  PID  PPID USER     STAT   RSS %MEM %CPU COMMAND
 4280  1191 user     S    16624  7.0  0.4 /usr/bin/modest
 4193  1461 user     S    14756  6.2  0.0 /usr/sbin/browserd -s 4193 -n browseru
 1029   703 root     S <  11356  4.8  0.2 /usr/bin/Xorg -logfile /tmp/Xorg.0.log
 1303  1191 user     S    10564  4.4  0.7 /usr/bin/hildon-home
 1805  1191 user     S     9128  3.8  0.0 /usr/bin/browser
 4434  1191 user     S     9128  3.8  0.0 /usr/bin/osso-xterm
The answer to your question 5 is, "it depends". If the real problem is that all your virtual memory is used up, then resetting swap is not going to help. That's where 'free' comes in. If, OTOH, some runaway background task allocated a lot of memory that got swapped out in a hypothetical situation such as what I described, then we need to find the culprit. Hence 'top'.
 

The Following User Says Thank You to pichlo For This Useful Post:
Posts: 359 | Thanked: 322 times | Joined on Jun 2010
#16
Originally Posted by pichlo View Post
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 CPU: 2.5% usr 5.3% sys 0.0% nic 89.4% idle 2.5% io 0.0% irq 0.0% sirq Load average: 0.09 0.08 0.07 1/205 4629 PID PPID USER STAT RSS %MEM %CPU COMMAND 4280 1191 user S 16624 7.0 0.4 /usr/bin/modest 4193 1461 user S 14756 6.2 0.0 /usr/sbin/browserd -s 4193 -n browseru 1029 703 root S < 11356 4.8 0.2 /usr/bin/Xorg -logfile /tmp/Xorg.0.log 1303 1191 user S 10564 4.4 0.7 /usr/bin/hildon-home 1805 1191 user S 9128 3.8 0.0 /usr/bin/browser 4434 1191 user S 9128 3.8 0.0 /usr/bin/osso-xterm
The answer to your question 5 is, "it depends". If the real problem is that all your virtual memory is used up, then resetting swap is not going to help. That's where 'free' comes in. If, OTOH, some runaway background task allocated a lot of memory that got swapped out in a hypothetical situation such as what I described, then we need to find the culprit. Hence 'top'.
Yeah, I had rebooted shortly before I took those screenshots, so I'll try to let it run a while and then take more screenshots when I have less swap memory available.

Thanks! I like a good mystery/investigation . . .
__________________
Hitting this thanks button will make you smile and feel good ----------------------------------------------------------------->
 
Posts: 1,808 | Thanked: 4,272 times | Joined on Feb 2011 @ Germany
#17
(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.
This is not necessarily true. If you've understood what @pichlo is trying to say from the very beginning of this thread, you'd know that swap is the same as ram, only that it uses disk

The kernel may well decide to use swap during boot, but this is not likely.

(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.
*MEMORY* is used. Whether it's DRAM or swap is only the kernel's business. Obviously, the more memory is used the less memory is available. If your free swap reaches zero there is a very high probability that your physical ram is also zero, meaning you can't do anything.

(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.
When a program exits its memory (both ram and swap) is freed. Now most programs are not self contained but use libraries and other "middleware" which is basically constantly allocating memory. Most programs written after 2000 basically don't care about memory and except that someone else will take care of deallocating it. The problem is that that someone else doesn't exist.

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.

(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.
This is the usual effect or having almost no memory availblle (if you have a VM at hand try running Windows NT 4.0 with 12MB of RAM and 16MB of swap. You'll see how I lived for about 3 years).

(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?
There's no way to achieve what you want. The only way would be if all programs that are running would be closed so as to free the memory they were using and then start again, which is not going to happen (at least in general).

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.
 

The Following 2 Users Say Thank You to reinob For This Useful Post:
Posts: 359 | Thanked: 322 times | Joined on Jun 2010
#18
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.
 
Community Council | Posts: 4,920 | Thanked: 12,867 times | Joined on May 2012 @ Southerrn Finland
#19
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...
 

The Following User Says Thank You to juiceme For This Useful Post:
Posts: 1,808 | Thanked: 4,272 times | Joined on Feb 2011 @ Germany
#20
Originally Posted by Hacker View Post
I still find it strange that things are this way, but c'est la vie avec N9.
Maybe this is a wild shot, but I just re-read above that the N9 has 768MB *RAM* and 256MB *SWAP*.

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).
 

The Following 3 Users Say Thank You to reinob For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 19:19.