Pandora Caching Suggestion for Pandora


Coldbird

Member
Joined
Aug 15, 2010
Messages
397
http://www.scottklarr.com/topic/134/linux-how-to-clear-the-cache-from-memory/


Take a look at that...


Sadly - all pandoras suffer from this issue... once its cached... you never get the memory back... which - at the moment - makes it impossible to use a Pandora as a dedicated machine for - lets say - a mobile proxy or in my case - a mobile hotspot repeater...


The description above, fixed the caching issue... so that cached data actually gets freed again sometime so apps can reuse the memory...


Now dedicated stuff works okay. :D


I suggest this gets incorporated as the new standard setting in HF6.
 
Wow, interesting. Is the OS simply not giving the RAM back like it should? I never considered that this sort of thing wouldn't simply be handled. Like the author of that blog above, I assumed that memory management was fine.


I have not experienced what he's saying on any of my desktops or laptops, but the Pandora can get a bit sluggish sometimes.
 
Hmm, is there a skeptical emoticon? Because I am quite skeptical of this claim. I'm quite positive that the OS will sacrifice cache for an application requesting memory space. That's just how all operating systems work.
 
That was over 3 years ago. Judging from the fast development of the Linux kernel, do you really think this is still relevant?
 
I experience this myself quite often on my Pandora, as I'm using the little box a lot for stuff people shouldn't use it for... :D


Since I followed this guys advice everything works fine caching wise.


Also, please keep in mind that the Pandora itself isn't "too up 2 date" kernelwise.


I wouldn't say 3 years behind, but atleast a bit.
 
Hmm, I'm still skeptical, though I do believe that ColdBird is getting a performance boost from something. Let's be constructive about it.


Say my Pandora is using 400MB for cache, 50MB for system stuff and running applications, and 50MB is free -- as shown by 'free'. I would assert that if I were to make a C program in which all it does is allocate 1MB of memory every 1 second without freeing any of it, at 50 seconds it will use up all of the 50MB of free memory, and after 50 seconds (well, probably sooner), the value for cache would start decreasing.


The above makes sense to me, and most people would agree. That's just how things work. I don't have my Pandora near me at the moment, but if someone wants to write it up, feel free to do so. If the article is correct, the C application will run out of memory in less than a minute because it won't be taking memory away from cache.


@Coldbird - what are you using to make your Pandora a mobile hotspot repeater (I know less than jack about mobile/smartphone stuff)? I can imagine a bug in that application that could be causing these problems. And the bug could be simple; the application, before asking for more memory, could be seeing how much is available and using the wrong memory value.
 
Now that's some bs article.

I experience this myself quite often on my Pandora, as I'm using the little box a lot for stuff people shouldn't use it for... :D


Since I followed this guys advice everything works fine caching wise.
You experience what exactly? It looks more like psychological thing of getting more satisfaction from memory tools reporting more free memory. You actually lose performance by dropping often used things out of memory like this..
 
I could post the ramdefragger I ported, then you could tell me, if it would have the same effect you experience ;)
 
I've got a jumper backwards on my desktop's motherboard. I hate it when that happens. ;)
 
I did used to have to do this on my Beagleboard. The driver for my wifi stick required a couple of megs of contiguous memory in order to connect, for some reason. It also had a bad habit of disconnecting every few days. If the cache filled RAM, and it needed to reconnect, thus requiring another request for contiguous memory, odds were the request would be rejected, the driver would do some flailing around a bit, and then the host controller would crash (not unlike what happens to the Pandora when you plug a USB1.1 device in) necessitating a system reset. My first "fix" had a job run which monitored the wifi and if it saw the USB host crash, it would reboot the system, and then try restore where it could; worked well enough to keep me mostly connected to IRC and keep my downloads going, but it still sucked to be rebooting every couple days.


Then I found this fix to dump the cache, wrote it into a cron job that ran at midnight every day, suddenly there was always lots of memory for the driver and it almost never rebooted.


Eventually the driver was updated to not be stupid with memory and I didn't need that particular hack anymore. I've currently got just 3MB free, but 66MB in cache (which fluxes up and down), and a 5 week uptime.


And then I found five dollars.
 
^ That's really exciting! Was it $5 Canadian or American? What did you spend it on?


But seriously, that's interesting.
 
I'd really REALLY like to see some test data on this claim, please.


Here's an oversimplification of how it's supposed to work (and does work on Linux, OSX, and Windows, until somebody can prove otherwise to me). Keep in mind that RAM has one of a few states:

  • In Use: A program's using this RAM, it contains some important and useful data.
  • Free: No program's tried to use this RAM yet, it's in the same state it was when your computer started (technically, it's filled with zeroes).
  • Cached: RAM that was recently used and isn't anymore, but still contains useful data that the system could start using again at a moment's notice.



  1. You start your computer, some RAM's used, some isn't (that's the "free" ram).
  2. You start a few programs, now more RAM's used, less isn't.
  3. You quit a few programs, and the RAM numbers don't really change... :\


  4. Right. That's expected. The RAM isn't used, but now cached.
  5. If you restart the programs you were running, the system will just reuse the RAM it was using (turning "cached" RAM back into "used" RAM). That's why programs start faster the second time you start them.
  6. If you start new programs, the system will consume the free RAM until it's exhausted. After that point, it'll start consuming the cached RAM. If you quit a few programs, that RAM will become cached again.
  7. When your system needs to consume RAM, but there's no free or cached RAM left, you'll get out of memory errors.



The commands "free", "top", "htop", "conky", and so forth, are great at displaying that sort of information.


The upshot of all this is that if your system runs for long enough, eventually it'll consume all the free RAM and everything will become cached. That's perfectly normal. Actually zeroing the RAM instead of just freeing it would be time-consuming and cause programs to restart more slowly. This is actually used sometimes, in applications where security is critical - where even having the data in RAM after the program quits would be a security concern (think encryption).
 
Last edited by a moderator:
Once a program have finished all his private memory is immediatly returnd to the free memory list : there is no way you can reuse this segment, so drop it.


Cached memory is for file operations. All reading from disk is put there with some magic to keep all the most revelants files in memory. So next time the program will want to read from this file, the read will be from memory instead of disk : you've just divide the execution time by 10-15.


When memory is full and a program want more memory, the system will just drop the least revelent file from cache and give that space to the program.


This is to put this "free memory" to some use, because beside it's name, RAM come with a cost : energy as it have to be refreshed on every cycle.


I know that it may exist such operating system that doesnt behave this way, but that's just plain stupid.


Edit : to be more clear, let's have an example with panmines.


When the game is started, the system read the executable file (about 400k) into memory. it then put all the requiered libraries (several MB ; those not yet there) into memory.


The game is now started and allocate it's working memory (about 20M) and read 2 font files.


Once the game is stoped, it's private/working memory is returnd to the free memory, while the font's, the libraries and the program is kept in Cache memory.


(I hope that's clear enough)
 
Last edited by a moderator:
Back
Top