Why is it that sometimes, closing an application on a phone decreases available RAM instead of increasing it?

226 views

Why is it that sometimes, closing an application on a phone decreases available RAM instead of increasing it?

In: 2

6 Answers

Anonymous 0 Comments

I’m no technology expert but it likely has something to do with storing memory or using something like cookies to remember where you were in the app. If it’s an app that runs in the background, closing it might use more RAM because the app is caching data to remember things the next time you open it

Anonymous 0 Comments

Hard to say where without knkwimg what exactly you are doing whem this happens, but likely you are opening a different app (using more RAM) to close the other app. Also, your home screen uses a lot of RAM so if you just switched to it, that would also decrease available RAM.

Anonymous 0 Comments

Closing an app makes the OS work some to save the app data and settings, that work can take up a bit of RAM. So leaving an app asleep in the background may be better then making the OS go through the process of saving info to flash.

And also there is some inaccuracy and guess-estimates going on to show how much RAM is in use, since it actually changing in sub-second ticks. And the task manager app using some RAM too, so the act of watching the system uses RAM.

Anonymous 0 Comments

**The Reason:**
Every system is different, but often app data is stored in RAM even if it’s closed to enable faster reloading the next time you open it. (It’s faster because that data doesn’t have to be re-written to memory again the next time it’s needed – a process which takes time)

This means that by closing the app and switching to another one, you’ll often see usage go up because you’ve launched another app (your home screen is also an app, so just going to the home screen is the same) and it also had to show a bunch of animations along the way, which takes additional processing and system resources.

Whatever memory management system your device uses can then just choose to erase, write over or re-use space from inactive apps as and when it sees fit, depending in what other things your device needs to do.

Having fairly full RAM on some systems is not always a bad thing. With a properly tuned system, it just allows for faster use of needed data in RAM, increasing performance.

Hope this helps!

**Fun fact:**
Many systems can actually use a compression algorithm with the data it stores in RAM, essentially gaining better use of the available space at the expense of some CPU usage. That means a 4GB disk can be made to fit way more in it than 4GB of raw files, for example, so the old joke about “installing more RAM” as a downloadable add-on is not actually all that mental.

ZRAM under Linux is an example of this, if you want to do some more reading.

Anonymous 0 Comments

I would imagine the app has memory allocated to it in order to work, the operating system then allocates additional space to handle shut down and system saves.

In programming there is a concept called garbage collection where memory that is no longer used is freed up. Most modern coders do not trigger garbage collection on closedown and rely on the operating system to do it, hence you will wait a while for your free memory to go back to normal.

Starting a new app will trigger garbage collection by the operating system so the memory is available immediately anyway.

This is quite simplified.

Anonymous 0 Comments

RAM is like a dinner table. Once one group is done eating, it needs to be cleared so that the next group has a place for their food. This usually involves a bunch of staff quickly clearing and cleaning the table. They’re very busy when they do this, but only for a few minutes.

I think we need to clear up a misconception. In *consumer* devices, unused RAM is a waste of resources. (In research and infrastructure applications RAM needs to be reserved for things like filesystem deduplication, virtual processes, and bursts of unexpected activity).

Processes on phone operating systems are far more optimized than their desktop counterparts, with garbage collection (reclaiming no longer used segments of memory) is more aggressive. This allows the OS architects more leeway to push the envelope.

*But why does RAM utilization go up?* You’re relying on the user interface to accurately report usage levels. But these levels are always going to be averages of a constantly moving window of *x* microseconds. In server/*X/BSD systems, this can be tuned to deliver more accurate data. For phones, it may be an average calculated over multiple minutes. Which makes sense. An end-user may get nervous if they see little usage surrounded by crazy spikes.

But that’s a more accurate idea of what’s going on. When an application is “closed” it tends save its state into RAM so it can be quickly reloaded. This may involve some rapid shifting of data into more contiguous segments of memory. It’s an optimization that front loads the processing in order to make subsequent launches faster.

When a mobile OS decides to actually terminate the thread(s) of an application, that part of RAM will likely need to be cleared immediately so it can be reapportioned to other processes.

There are also architecture differences between the x86/AMD64 processors that traditional computers use and the ARM processors that are favored by devices with more stringent power requirements.