• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Free ram is wasted ram... or not?

navel

Lurker
Hi guys!

I'd like a lot to know your opinion (and if you agree) about the statement that the v6 Script Supercharger author has done on this topic:

"Do:
cat /proc/memfree
The cached data is "invisible" to most free ram monitors in that it is included in the reported free ram. This is why you always hear "free ram is wasted ram blah blah blah" I'm thinkin no ram is really wasted. I don't think I'm a linux guru as I've never ran a linux pc. But I've read enough that I can make sense of the numbers and their effect. Seriously, if free ram is wasted ram then the phone would never slow down when low on ram and it wouldn't get snapply after killing a bunch of apps. This proves that the "free ram" is actually "doing something" and if it's doing "something," then it's not really wasted, is it? Sorry gurus, but that "wasted ram" mantra makes zero sense. The trick is to find the free ram level (includng cache) where things start to slow down. Anything above that won't bring any benefit and needlessly detracts from multitasking...
To summarize: Performance degradation occurs when AFM decreases. Which is fancy talk for: "Lag happens when free ram goes below the 'lag level'"
So yeah... next time a guru says "free ram is wasted ram," the reply is: "Define 'free ram'."
Because if they mean free ram as reported by most apps (ie. MemFree + Buffers + Cached), they are 100% wrong."


I invite you to read this topic too.
I'm wondering if it's correct to say "wasted ram" or not... :confused:
 
In the most simplistic terms, here is how it works, and why "free RAM is wasted RAM," but also, why you don't want all RAM in use at any given time.

If an application is not in memory when you try to open it, that application haa to be loaded into memory, thus triggering a "load time." Having the application in memory (prefetched) prevents this load time and has the application load near insantly. This is why a modern OS will preload our most commonly used applications into memory. The more memory that you have, the more applications that can be preloaded, the smoother your device will run. Clearing this memory gives you no immeidate benefit, and will actually slow your device. Idle applications in memory consume almost no resources (CPU cycles, battery power, etc.). If an application is consuming resources, that means that it is doing something. Closing it will only force the application to re-load. Using a task killer for this purpose will cause a "boxing match" where the task killer closes the application, the app reopens itself, and back and forth. THIS will consume resources.

However, you want to have some memory free. Your devices will not have enough memory to preload EVERY application, so it has to guess based on your actions. It needs to have enough memory available to quickly load an app that you may want.

Let's say that you want to load an application that requires 256MB of RAM, but you only have 128MB available. This means that the OS is going to try to clear 128MB of RAM to accomodate your app, and as your app loads, will try to clear another 128MB to return to its previous state. This clear/load/clear causes a longer load time and more slowdown than just loading an app not already in memory.

So, the ideal situation is to have most common apps in memory (pre-fetched), but enough memory available to handle 1-2 common apps that are not already pre-loaded. Touchwiz (Samsung) devices allow you to clear memory from the task manager. My S2 had about 870MB of user-available RAM, and if I trashed all apps, it would go as low as 300MB in use. This may look cool, but it is a complete waste of resources, and the OS is simply going to re-load those apps over the next 2-3 minutes anyway. And if you use a task killer to keep your device idling at 300MB of available RAM? This is simply going to slow down the device, harm the battery, and give you the same memory performance and availability that you would get with an HTC G1. Welcome to 2008.
 
Just because the phone slows down when it has no free ram doesn't mean the "free ram is wanted ram" mantra is any less correct.

The saying doesn't suggest using up all your ram, rather that its best just to let android do its thing and not try to constantly kill off all of your apps.
 
Im on the international version of the galaxy s3 so it only has 1gb ram and most of the time im sitting with around 90mb free ram and it runs just as well as having 500mb free exept that cached apps open faster. Id post a screenshot but the fact is that ive remapped the button that shows me how much free ram i have and lets me clear it... thats how "much" i bother about ram these days lol.
My theory is that when people reboot and the phone speeds up, its because its clearing the app cache. Not because its clearing ram.
I dont recommend task killers but i do recommend the "app cache cleaner" widget because in my experience, even on a high end phone, clearing the app cache does work when scrolling gets choppy or the keyboard gets laggy. Thats probably down to bad apps and not android's fault :thumbup:
 
Thank you very much for your helpful explanations guys :)
At the beginning I had some doubts because I thought: "If I have more free ram I have more cache used by OS so more performance... at this point why we have to say that it's wasted?" For example actually I have 120mb free ram. Running the terminal emulator and giving this command: cat /proc/meminfo I discover that I have almost 100MB as "Cached" and 20MB as "Memfree" which should be the TRUE wasted ram from what I understood. On the contrary when I have about 72 MB free ram the command shows me that I have about 59 MB as "Cached" and almost 14MB as "Memfree", so I have less ram for file system caching! And this topic explains better what I mean...
By the way I agree about task killers: they are totally useless and fortunately I stay away from them ;) The only thing that I do to optimize RAM is to change the minfree values through the v6 Supercharger Script which works great for me. You know, I actually have an old device (Acer Liquid Metal) and this script is a manna from heaven :)
 
Worrying about RAM became defunct as of Android 4.x and devices designed to run it. RAM remains an issue with lower-end Android 2.x products after you install enough apps that start fighting for space in extremely low RAM to begin with. Try putting a JB ROM on the HTC Dream, a device that has support for it ironically despite the 192mb of RAM. then attempt to run Angry Birds? It will try to load and dump you back to the boot animation because it kernel panics. A logcat will say 'panic occurred: out of memory '

That of course doesn't mean that Android's Memory management sucks, but that you're attempting to run software meant for say, a Nexus 4 on a device over three years old. Like running Windows 95 on a 386DX and expecting the performance of a Pentium.
 
People who say you don't need to watch your memory usage are talking nonsense, keeping an eye on memory usage and what applications are active in the background is generally a good idea.

My Nexus 7 often lag's when there's too much going on and apps don't close, killing all the active apps solves this every time and that's on android 4.3. :confused:

I think Android does a good job overall managing memory but once you start downloading apps from the market it's really all down to how these applications behave.

A current annoyance for me is play music, it doesn't use much memory but does stay active in the background and wakes your device randomly which drains your battery.

Now if an app from Google does this what do you think happens when you install 20+ random apps from the market? Yeah, you need a task manager. :p
 
when i still used my Samsung Precedent, a device with literally 256MB RAM and Android 2.3 (had to flash a ROM for that, it came with FroYo) i had to edit tons of values in ROM Toolbox Pro, specifically minfree and VM heaps, and use the autostart manager inside that program to only allow certain apps to load into RAM, mostly notification, background services for apps i used each day, like Play Music, Books, and Facebook, and my Email sync. i couldn't let the device get over 75%-85% usage of memory, as it panics at 86+%. it started to lag around 83% usage, which meant less than 20MB free RAM. after my hacks, it was a very fluid phone, no hiccups or lag in scrolling or transitions. however, being such a low-end product, meant that while transitions were plenty fluid, it still had long delays launching large apps, often greeting me with a black loading screen and possibly some 'app not responding' dialogs. my edits also stopped Android's built-in manager from killing the custom launcher i used and preventing the subsequent redraw lag and dozen ANRs in the process whenever i'd back out of an app.

it wasn't a 'task manager/killer' that solved my problems, it was knowing enough about Android to fix problems via rooting and hacking and not messing it all up. think of task killers/managers as pain pills. they may cloak the pain of a headache, but don't actually 'cure' the headache, and often come with some unexpected side-effects as well.
 
People who say you don't need to watch your memory usage are talking nonsense, keeping an eye on memory usage and what applications are active in the background is generally a good idea.

My Nexus 7 often lag's when there's too much going on and apps don't close, killing all the active apps solves this every time and that's on android 4.3. :confused:

I think Android does a good job overall managing memory but once you start downloading apps from the market it's really all down to how these applications behave.

A current annoyance for me is play music, it doesn't use much memory but does stay active in the background and wakes your device randomly which drains your battery.

Now if an app from Google does this what do you think happens when you install 20+ random apps from the market? Yeah, you need a task manager. :p

Now that your N7 is on 4.3, you should give it a full wipe and start again to benefit from the "trim". The nexus 7 doesnt lag due to ram.. its the hard memory causing the problem but the trim feature in 4.3 should cure that. As i said though, your gona have to fill the storage from scratch to get the benefit of it :thumbup:
 
there is a bug where Google Chrome freezes, panics, and reboots the system, specifically when you are busy typing a ton of text, on 4.3. it also seems to have a memory leak as well (maybe causing this problem) that if you back out, it seems Android kills the launcher and you wait for it to redraw, which, isn't a big deal on a Nexus product but it does play up with some of my widgets which lose some of their settings when it happens.
 
Now that your N7 is on 4.3, you should give it a full wipe and start again to benefit from the "trim". The nexus 7 doesnt lag due to ram.. its the hard memory causing the problem but the trim feature in 4.3 should cure that. As i said though, your gona have to fill the storage from scratch to get the benefit of it :thumbup:

I've already done a full wipe, then explain to me why after clearing running apps the lag disappears? or are you saying its just coincidence?
 
Now that your N7 is on 4.3, you should give it a full wipe and start again to benefit from the "trim". The nexus 7 doesnt lag due to ram.. its the hard memory causing the problem but the trim feature in 4.3 should cure that. As i said though, your gona have to fill the storage from scratch to get the benefit of it :thumbup:
You do *not* have to wipe and start from scratch to get the benefits of 'TRIM'.

@Shocky: I pay absolutely zero attention to memory usage and have zero problems.
 
sorry guys that was just how i understood trim to work, i thought it had to be there while you filled the storage to work. Havent read up on it though. Nah im sure its not coincidence that killing apps speeds it up but i dont know why it is. I dont understand this stuff enough to call it. I just have faith in what the smarter people say lol :beer:
 
Back
Top Bottom