View Single Post
dantonic's Avatar
Posts: 361 | Thanked: 108 times | Joined on Sep 2008
#22
Originally Posted by shadowjk View Post
In the case of opening many many windows in the browser being fast-ish the first time and slow-ish subsequent times is partly a side effect of swapping to sd/mmc.

Despite what you might think, random writes to flash are very very slow. A 4k write from the OS/device migh require the card itself to first read 256-512k of data, modify 4k of it, and write back 256-512k, because its native block size is that huge.
You don't notice this causing any slowdown with photos, videos, songs and so on, because they're pretty large.

The first time you push your tablet's memory use close to and over its physical SDRAM capacity, the swap file/partition is empty, the OS can pick whatever it wants from ram that it thinks is least needed and write it out sequentially. It might achieve rates of over megabyte per sec the first time.

After you've closed the browser, you might use programs that had parts of themselves swapped out to flash, those get read back in then on a as-needed basis. A copy is retained on flash in case the os wants to swap out that exact same thing again it wont have to write, it can just drop it from ram. The program might write to or change that memory though, in which case the chunk on flash is freed and has to be written again if OS wants to swapout. A form of fragmentation happens in the swapfile.

Thus, the next time you open loads of browser windows, the swapout of other programs wont happen sequentially to flash, instead it will be a little piece here, a little piece there, in random order. This is extremely slow compared to firt time. It's not unusual for memory cards to drop to speeds of 16 KILObytes/sec or worse under such loads. Brand name cards no exception. Higher class cards might help, unless they consist of multichannel flash in a parallell setup, which might make blocksize bigger, which makes random write speed worse (but boosting sequential write speed).

So one source of slowdown over time is swap "fragmentation" and flash-based storage's inherent allergy towards seek-heavy write loads.

Programs themselves might grow bigger over time due to internal heap fragmentation as well, which will make you run into swapping faster.

Neither of these things are memory leaks.
Thanks for that explanation, but (and I'm might be wrong I'm new at this) if I don't have virtual memory enabled, I am NOT using swap correct?

If that's the case, then this is still happening even though I'm not using swap.