Notices


Reply
Thread Tools
Bundyo's Avatar
Posts: 4,708 | Thanked: 4,649 times | Joined on Oct 2007 @ Bulgaria
#21
And on top of that, there is something else:
https://bugs.maemo.org/show_bug.cgi?id=2615
__________________
Technically, there are three determinate states the cat could be in: Alive, Dead, and Bloody Furious.
 
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.
 
noventa98's Avatar
Posts: 122 | Thanked: 51 times | Joined on Nov 2007 @ Paris, France
#23
Maybe it is unrelated, but I often experience periods of unresponsiveness (5 minutes or so) when I pick up the tablet the next day after I left it with some open applications (mostly the browser microB). After that things go back to normal behaviour.
 
dantonic's Avatar
Posts: 361 | Thanked: 108 times | Joined on Sep 2008
#24
Originally Posted by noventa98 View Post
Maybe it is unrelated, but I often experience periods of unresponsiveness (5 minutes or so) when I pick up the tablet the next day after I left it with some open applications (mostly the browser microB). After that things go back to normal behaviour.
Well it's just that my load applet ends up showing more bars, and they don't go back down.

I've enabled virtual memory, hadn't used it till now, this should make it better I assume.
 

The Following User Says Thank You to dantonic For This Useful Post:
Posts: 1,258 | Thanked: 672 times | Joined on Mar 2009
#25
I'm not sure about jffs2, which is the filesystem used to store all the programs on the tablet, but atleast in standard linux there's a sorrt of swapping without virtual memory. A program consists of executable code and resources that are hardly ever changed, in a low memory situation, Linux can remove code of loaded programs that are inactive, since there's a copy on flash anyway. Programs also use some shared resources in the form of libraries, they might get the same treatment.

So, for example. Program A gets loaded when you boot the applet. A uses Library B, which also gets loaded. At some point, when you're using a Program C, the OS gets low on available memory, and might notice that there's no swap/virtual memory available, but parts of Program A and Library B hasnt been used for a long time, and the contents in memory is still same as it is on flash. It drops those parts from memory and makes a note to load it back from flash if it's ever needed again.
Now later you want to use Program D, which uses Library B. It will take slightly longer to load because both D and B has to be read in from flash, compared to just D when tablet has just booted.
Also, switching back to or using A can cause a delay.
These delays could be a few seconds long, I'm guessing.

There's actually a project for Linux called preload that keeps track of what programs you use, and if it notices there's free memory (as there would be after you close the browser, for example), it gives hints to Linux telling it to read stuff from flash and fill the memory with stuff that could be needed, so that you get faster response.

All in all, memory management and handling is quite advanced and complicated in a modern Operating System, and especially measuring memory use can be extremely hard to do

Of course, it's entirely possible still that some things do actually genuinely leak memory...
 

The Following 2 Users Say Thank You to shadowjk For This Useful Post:
dantonic's Avatar
Posts: 361 | Thanked: 108 times | Joined on Sep 2008
#26
Wow thanks so much for that explanation shadow.

Very interesting the way it works. So when the OS stores part of the memory on flash to make room for other apps, maybe the Load Applet shows more memory being in use because it has in it's memory instructions to point the OS to the flash locations.

So in other words, even though certain programs are no longer left in memory, some memory is still taken up to point to the the flash location where the "library" in question might be for example.

Could this be what causes the load applet to show more memory in use even after closing all applications?
 
Posts: 1,950 | Thanked: 1,174 times | Joined on Jan 2008 @ Seattle, USA
#27
Per qole,
a good fresh flash makes everything work better again. Especially if you don't use the backup and restore function. Copy your documents to the SD card, flash the tablet, and then install everything fresh.

I was surprised at how much cruft had built up.
I'm loathe to flash and restore, especially without using the backup function to get my apps, since I have such a wonderfully tweaked Tablet currently.

But I wonder, do other people have qole's experience? Does starting fresh really make everything work better?

The only complaint I have about how well everything works is that MicroB or Tear can stall out, and it seems I need to restart to get browsing back up to speed. Occasionally some other program will crap out and shut unexpectedly, but not often. I'm not sure it's worth rebuilding from scratch when, for the most part, everything works so damn well.
 
Posts: 1,258 | Thanked: 672 times | Joined on Mar 2009
#28
I'm not sure how load applet measures memory use, but generally if you close a program, all its executable code and libraries are kept in ram memory. You might notice this if you time how long it takes to start media player the first time, close it, and start again a second time right after. Might start faster the second time. Linux philosophy is free ram = wasted ram. After that, it's all about trying to be clever in deciding what to discard from ram when the need to load more stuff into it comes. Ideally you'd be able to predict the future and remove things that wont be used for awhile and load stuff that will be used soon, but predicting the future is notoriously difficult
 

The Following User Says Thank You to shadowjk For This Useful Post:
Posts: 4,556 | Thanked: 1,624 times | Joined on Dec 2007
#29
Originally Posted by GeraldKo View Post
Per qole,

I'm loathe to flash and restore, especially without using the backup function to get my apps, since I have such a wonderfully tweaked Tablet currently.

But I wonder, do other people have qole's experience? Does starting fresh really make everything work better?

The only complaint I have about how well everything works is that MicroB or Tear can stall out, and it seems I need to restart to get browsing back up to speed. Occasionally some other program will crap out and shut unexpectedly, but not often. I'm not sure it's worth rebuilding from scratch when, for the most part, everything works so damn well.
What I do is use partimages to make backups. It doesn't solve the problem if it's crufted up already. But if things go wrong or your unhappy with performance. A fix is just a full restoration away!
__________________
Originally Posted by ysss View Post
They're maemo and MeeGo...

"Meamo!" sounds like what Zorro would say to catherine zeta jones... after she slaps him for looking at her dirtily...
 
Reply

Tags
memory leaks


 
Forum Jump


All times are GMT. The time now is 01:35.