Memory Management and Operating Systems
Two most popular operating systems that power almost all mobile devices on the planet are Android and iOS. Though they have many similar things, with one similar to another, the two aren’t much different. Differences do exist in their memory management.
Before understanding this any further, memory management here means how the two systems make use of their RAM (Random Access Memory). RAM is defined as a way computers and smartphones access stored files. Unlike hard drive i.e. local storage, RAM is temporary storage. this means, things inside RAM, aren’t permanent like those stored inside hard drives. Smartphones are devices with a more limited size. there is a small difference between how RAM is used on these devices as compared to that on computers. However, they are basically the same, as it is used to deliver instructions and data to the processor so it can be processed, reducing load time and allow users to move from one app to another quickly and without any hassle.
How RAM is related to your storage and speed?
RAM is used to read data when the system needs it. There is a myth since RAM delivers data a lot quicker than when the data is stored inside the main or local storage, the more RAM a device has, the speedier it should be. Apparently, this is not always true.
Android phones do have quite a lot of memory these days. In some cases, they have more memory than many desktop computers, and much more than iPhones. Does that mean Android is better at multitasking? Or does it make iPhones less capable in running complex processes? The answer is NO. This is because the differences exist in their memory management.
On Android devices, complex processes happen when there is multitasking or apps are running side-by-side. These devices allow apps to run on their own virtual space with virtual memory. On Android’s devices, the memory is given to the system, the rest of the memory is divided to be used by each apps depending on their usages. Any RAM that isn’t in use, is free. A good system shouldn’t have any free RAM for operation, but available RAM. Android manages its RAM for things like caching storage when users reuse an app and keep the system to always use RAM to relocate data(cached data which is collected by a running app & left there on storage once the app is killed or terminated). This allows the operating system to quickly switch from one app to another, from one screen to the next, with relative ease, as long as there is RAM available.
Since Android is an open-source operating system, the main disadvantage of this Android memory management is the way Google and other developers handle their apps from the way they are built and created, to how they behave in the background. This makes complicated issues.
Memory aspect: Android vs iOS
Understanding this a bit deeper, Android uses Java. Java can run on any processor. This means it can be ported by many smartphone manufacturers running different hardware configuration. In Android’s case, Java runs via a virtual machine, which is like a virtual layer between the actual hardware and the software. This is a huge drawback because a lot of memory is needed to run a virtual machine, and even more memory is needed to store both the Java-code and the machine-code for a processor, as well as store the system-needed resources for translating the Java byte-code into the device’s processor machine-code. This virtual machine is based on a method called ‘garbage collection’ resulting in ‘cached data or cache’.
<<Also Read: EdTech or Education Technology>>
Android Apps use as much RAM as they need, taking advantage of the available RAM whenever possible. When a new app is launched within Android, the garbage collector’s job is to enumerate all objects allocated by those apps, mark all reachable objects, to then free up whatever RAM is left remaining. In short, garbage collection is essentially a way for Android to recycle memory once an Android app is done using it. This method is effective, but it works by consuming much RAM. Otherwise, the system will spend too much time collecting garbage & ruin overall performance.
Now talking about iOS most notably, iPhones have less RAM than Android phones. But Apple has a reason for that: it doesn’t need as much.
Android apps are mostly freer. They can access services or perform post-processing background tasks in less restriction than in iOS, which is a good thing, but it can be bad because apps behave in weird ways because of that freedom. For example, developers of an Android app can make the app to stay persistent in the background resulting in the consumption of RAM that otherwise can be used by other apps.
<<Also Read: The Bent-Neck Generation | The dark side of technology>>
Whereas Apple has a more controlled strategy. The operating system chooses whether an app can do something or not when it’s running in the background. iOS allows users to open more apps and having them running the background, longer after users have finished using them. iOS was designed to run Objective-C applications on known hardware, which is an ARM processor. Because Apple has full control of the hardware, the company could easily make the decision to have native machine code running directly on the processor without a virtual machine. This practically saves a lot of memory requirement. What’s more, iOS doesn’t have that ‘garbage collector’. Instead, every process created on the operating system has a count associated with it. This is called the ‘Retain Count’. A newly created object will be assigned a count of 1. During the course of the process’s life cycle, the Retain Count can increase or decrease accordingly. But the rule here is that once the Retain Count reaches 0, the operating system immediately kills the process.
Details
Apple introduced ‘Automatic Reference Counting’ (ARC), iOS can automate the process, with the compiler inserting the appropriate Retain Count to the code before building the binary code. This memory management is a major advantage over Android’s garbage collection. This is why iOS devices run so fast while having lower specifications.
In today’s market, Android phones have humongous RAM, that increases all the time.
An example of this reason: If a user closes a web browser and then relaunch it, the browser opens the last page that was opened. this is because the system saves the URL, not the actual page. Android has a mechanism which sends a warning to apps running in the background to store the most important information because when RAM is low, the app can be terminated. Apps only keep what’s extremely important. Because of this particular reason, Google and other manufacturers will always go for more RAM in their devices as an alternative to keep processes running efficiently without having to terminate them all the time.
But for iOS, Apple has a software-driven solution: its iOS operating system is less dependent on hardware because iOS runs natively on the hardware, unlike Android.
Android tried solving its memory issues, one of which is by using Android RunTime (ART) which replaced Dalvik. This runtime is optimized to take advantage of the target processors as much as possible, but without adding any necessary compatibility for new architectures. ART is written to run multiple virtual machines on low-memory devices by executing DEX files, a bytecode format designed especially for Android that’s optimized for minimal memory footprint.
Join our free CAT course (click here)
One Comment