Android vs iOS RAM management - Who does it better?
Вставка
- Опубліковано 9 чер 2024
- Following my videos on how much RAM you need for Android, and in an iPhone, here is the third part: Android vs iOS RAM management - Who does it better? Do iPhones need less RAM? Is iOS better optimized? Let's find out.
How much RAM do you really need in an iPhone? (2022 Edition) - • How much RAM do you re...
How much RAM does your phone REALLY need in 2022? - • How much RAM does your...
Let Me Explain T-shirt: teespring.com/gary-explains-l...
Twitter: / garyexplains
Instagram: / garyexplains
#garyexplains
This sheds a lot of light on why Android needs more RAM than iOS. Excellent insight Gary.
yea people will still just assume "optimization"
@@sireajeel5009 Sure call it whatever you like, but what are the advantages of the android way vs ios? What is the purpose of writing an app in java only to use android APIs which means it can only run on an android device. Wouldn’t it be better to write native apps for android on ARM which nearly all use?
Yeah cuz IOS can handle better on ram management.
@@AestheticBlack1 you literally missed the point of Gary's ram explanations.
@@sireajeel5009 Well it quite literally is optimization. On iOS apps run natively while on Android they run through compatibility layer. You can never optimize the apps to run as efficiently on Android devices as you can on iOS devices since it's basically like comparing to running a program in emulation vs natively. Native will always be more efficient. And its for this reason I switched to iPhone.
Great trilogy Gary, really informative & plenty helpful. Thanks & keep em coming!
As an android developer, I am confused. Does it mean that writing Android apps in Flutter or Xamarin, which as per my understanding, compiles to native code, is more efficient as compared to writing it in native Kotlin / Java? Can someone please shed some light on it
Depends how you define "efficient". Power? CPU? Memory? But yes, Flutter apps would be smaller and likely faster. Not so sure about Xamarin because C# also uses an intermediate language like Java.
Flutter gets very close to native on Android. if writing native vs flutter, you will see file size higher on flutter due to some overhead, but, I am unsure of RAM management. I bet it's very close to native.
@@JoshuaPack if flutter and Java are not native for Android, what is ?
@@rishirajsaikia1323 the Android Native Development Kit is a toolset that is provided by Android to use C or C++ code in your Android application.
So, I would think C and C++ would be native code.
Android has used ahead of time compilation for MANY years now, so it compiles down to native machine code during the install process.
So using the native way would be the fastest. (Android SDK for Kotlin/Java and the NDK for C/C++.
You can read through the documentation on the Android developer documentation site. I don't want to post a link, since those get deleted quite often, but I'm sure that as a fellow Android dev you know where to find it.
Great content coverage as always! This was a comparison that I really wanted to see
This is so informative and interesting. Thank you Mr.Garry for this.
Gary I remember you saying in a video a couple of years ago that IOS compressed apps more into RAM than Android (compressed apps were smaller). Do I remember correctly? Is this still true and therefore does this contribute to IOS needing less RAM for similar results?
I also remember that!
watch the video he released about ios compression couple days ago
@@xeon2k8 I don't remember watching him compare the amount of space taken by the compressed apps in each OS in that video. I might be wrong tho
@@xeon2k8 he didn't answer this specific question in that video, he just showed some charts, it's not clear if IOS compresses more
@@_Digitalguy that's within "ram management" he's talking so much about. So the answer is NO, it's the same.
I just want to say thank you for these videos. They are very informative and enjoyable to watch.
This was very informative. I knew it was because of Java's runtime but didn't think the difference would be this much.
That was a beautiful explanation. Thank you guru !
Great work for the explainer Gary, thank you.
Wouldn't the AOT compilation (which happens at install time) in current android versions mean that android phones execute native code without a virtual machine overhead too, thus reducing the memory footprint? I think I'm missing something here...
The problem is the overall model of Java (things like garbage collection) mean it uses more memory even when you use AOT. AOT helps with performance, but not so much with the way Java is designed and how it is designed to use the run time environment.
Current versions of android use both, so it doesn't really matter. They'll do some AOT but use JIT while running where doing AOT wouldn't help since AOT uses more storage.
What an excellent explanation! Thanks Gary!
Thanks Gary....very informative.
Thank you for the explanation Gary👍
Your videos are excellent! Very Informative!
Great explaining man!
Great video! That clarified alot for me
This was a great video. Looks like I've found a new channel to binge
Such a good explanation!
You just came to the major point in the beginning 👍 respect to you Gary.
Great video professor.
BTW would you make a video about the speed of RAM and how many channels can we have on an SOC?
Thanks for the explanation !
Thank you very much! Very informative
Gary you're the best! Hope you'd do C programming content again.
What subjects in C would you like covered?
@@GaryExplains or maybe even rust
what do you think if we rewrite stuff on rust is it true that rust will just magically make everything faster what if swift runs on rust runtime, not obj-c ? for example
I think that's can be interesting
@@GaryExplains Not basic C tutorials but like using C on low level stuff maybe? Or comparing C with other languages on some specific task? I really like how you show some stuff and you tell what can be done more and you leave it and it makes me to try out and continue. Multithreading, ipc, network programming stuff seems scary to all of us, maybe you can make a few videos on this topics? I don't know, whatever you upload, it's great but watching you coding is kinda cool.
Did you watch my two videos on Piccolo OS?
@@GaryExplains I don't know how I missed that videos, they're great!!!! I'll definitely watch deep down and try out more stuff!
Hi Gary, can you give us an update on the modern chips on how they are performing and where they are heading after the new Exynos comes out mate?
Thanks for the great video!
I remember my iPhone 4S able to save games minimized for weeks and the games never got killed. Now? My iPhone 11 Pro Max killed my image viewing apps like 5 mins after minimize and my games instantly when I accidentally swipe it away haha. It's so much less reliable now. Going back to home screen now doesn't feel like minimize, feels more like ending task.
Love you Gary. ❤️
Lots of people say "optimized" without understanding it. It's like a buzz word. Very informative video
Great video Gary , very informative , and this explains some of the inconsistency when doing speed test on different phones .
Thanks for this explanation
Probably my favorite channel on UA-cam I love knowledge
This is best explanation I have seen.
Thanks. Yes, when iOS and Android were devised each had a decision to make and Apple went their way and Android, was aimed as an open source. I feel that each has pros and cons making that decision and one of these is that iOS is lighter on RAM. It has been noticeable since the early days. I think for the vast majority this is not an issue going forward as 6-8GB of RAM on Android will be fine for most users. More a concern for me is how OEMs manage the RAM, seemingly conserving battery over user experience. My S20U has 12GB of RAM and even when most is used I do not see an issue with battery life so I do wonder about the cost benefits of this intrusive RAM management.
I do not need all the Android benefits so I do appreciate how well iPhones now handle RAM, though it was a lot more hit and miss a few years back.
You earn a sub for the good work.
This was a really nice analysis. But it only considers a piece of the problem. You’re addressing the effect of native code vs JIT, and how the runtime, kernel, and executables affect RAM usage. The other bit is the SDK and how well it’s written and optimized. It’s difficult to compare two apps on two platforms and their effect on RAM usage because the code based and underlying frameworks are different. As you pointed out, apps that are games that are built on common underlying frameworks that work close to the metal…they’re closer together. They don’t rely as heavily on system UI frameworks. But other apps that DO rely on a lot of system UI frameworks and designs have a bigger divergence. I am an iOS and an Android developer. I admit I’m not a knowledgeable about underlying implementations of Android ‘Widgets”, but having developed for iOS for over a decade, I can say Apple has a lot of optimization techniques for their frameworks. For example, cell prefetching for TableViews and Collection views. That doesn’t relate to RAM as much as Disk and Network IO, but the point is, they put a lot of thought into optimization. And because they own the whole device stack, they can do a lot with that. Back to RAM, iOS makes more and more use of Value types in the SDK. In many cases these value types can drastically reduce memory usage because they can go directly on the stack and not incur heap memory allocation. Even value types like string (which implicitly require heap allocation because the string could be huge), actually have a “Small String Optimization” where it can squeeze small strings in line on the stack and not allocate a heap backing store. Being on the stack also means the values are created and destroyed pretty efficiently and don’t linger around consuming RAM. Even Arrays, if their contents are structs and can be stored in-line, can avoid creating a heap buffer entirely. In Java/Kotlin, outside of what they call “primitive types”, all of their stuff is an object and has to be allocated and then garbage collected. That’s why for a time - maybe still do - they discouraged using Enums and instead preferred integer constants because it consumed less RAM. Swift doesn’t have that problem since Enums are a value type and is created on the stack. Kotlin arrays are also reference objects which I can’t stand.
Again, I’m not as knowledgeable about android SDK, so some of these things might be a little out of date. But the point is you can’t just talk about the runtime and the compiler, when talking about ram usage and say that optimization has nothing to do with it.
This is the most important video in ios and android ram dialog of all time. Should be a precursor to even having a conversation about RAM
Great video! It's a relief that most games are native on Android. And it's surprising to see interpreted code apps giving native apple apps a run for it's money.
As an android fan it absolutely kills me to know that no one will ever make native versions of apps. But this approach is the reason why android is widespread. Basically all android manufacturers dont have to worry about designing an OS from scratch, and deploying apps becomes simple. There are tons of benefits of this approach. And at one point, when processor become truly powerful, it will be a turn-off for devs to go for native approach
Flutter is getting very popular and builds in native code with very little overhead. If we see more developers build in flutter we will see better apps too, and I there is a rise in that.
Calling it interpreted code is not exactly what is going on. JIT or AOT compiling are not the same as what an interpreter does.
@@JoshuaPack Google launches too many new development tools if you ask me. Kotlin is Google's best attempt so far.
Android is still just a gobbled Linux. They don’t have to stick to that ;)
You are just brilliant .
Extremely good test, and I like how you’re very neutral about it all. Keep it up.
Something about Java portability that wasn’t mentioned, is that Java needs to run on all the OSs that it’s intended to. Therefor, the features it may support on each platform will be those that are commonly found on all of them. Often,, features that are found on one, but not others, aren’t supported. So you get a neutered result, and that’s one objection to Java. Of course, if apps for Android aren’t intended to be portable, and not all Java apps are, then you will get Android’s features, but it has to be used on Android, unless another OS is developed specifically to duplicate Android’s functionality.
Aside from the JVM, which IMAO should go away for mobile devices, I think it might also be relevant that the JVM, or at least all languages I know to run on it, are Garbage Collected, while Swift and Obj-C are reference counted.
Garbage collection tends to just eat up RAM until a limit (per App, this is not related to OOM behavior of the OS), only after which it checks what objects can be deleted.
Considering that most apps you looked at were in the 200-300MB range that might also be relevant here.
Im not certain how this relates to code that went through the JIT or AOT compilation.
Also, while I think Kotlin fixes many of the issues with Java, it often not only costs performance, but also memory and especially binary size.
Many of the features that Kotlin has, will just get compiled to some inline code at invocation spot, instead of seperate functions.
thank you buddy
I'd love to sit down over coffee and discuss my love of all things smartphone with you, Gary. It would be a tech nerds, like me, dream. Lol. Good work my friend
dude its not 70% larger than i phone its actually 300%
in case of ebay you should calculate (300 - 69)/69 *100% = 335%
but i guess you calculated as (300 - 69)/300 *100% = 77% which is wrong
Exactly, I don't understand how it could be only 70 % when the apps shown in the table were about twice or even three times more memory hungry for Android.
He meant to say iOS is 70% less
@@JoshuaPack But then all the recommendations how much you need RAM for Android vs iOS is not correct as well.
Nice to see someone doing some research to explain what really is going on. Thanks.
Glad you enjoyed it!
can you please do how the jit and ahead of time compilation happens in android specifically? like an in depth analysis on different techniques used in java to make code run as natively as possible
Nice idea, but too niche, I think.
@@GaryExplains not really. Many android app devs follow your channel. It would be great if we know how internal systems work on android.
As I said, nice idea, it would be interesting, but I have all the stats and analytics at my fingertips and I know it is too niche.
@@GaryExplains You are the boss :D Maybe you could make a video about us, viewers. Who we are, what are we interested in.
I have a galaxy s21 ultra the 12 gig model it's really good so much so it rarely kill apps to save ram memory
Hey Gary, can you compare Gpay native and Gpay flutter RAM usage in android ? I noticed since few updates, Gpay is now based on flutter.
Running adb shell cmd package compile -m speed -f (app package name here) seemed to reduce app memory usage for me.
Great video, but what about the ram hardware itself? Iphones in general give the latest hardware tech best overall compatible. Wheres for Android due to such a large number of smartphone brands one has to be always sceptical going from product to product irrespective of coarse specifications. There are so many dram products with varying performance but same overall memory size.
The iPhone 13 Pro only have DDR4X ram while the Galaxy S22 Ultra has DDR5. The performance difference is not significant on a phone, but there are slight power efficiency improvements with DDR5.
Wow I was looking for the answer to this question.
Gary, can you do a video on how well or how easy it is for apps to take advantage of saving the state you are in with an app when it is killed and then you go back to it and you are loaded right back to where you were but in reality the app needed to reload from scratch. Or is that only when an app goes to the background?
I knew it... You nailed it on the wall of YT Videos
Most Android Apps often can run on different CPU architectures out the box. Which is extremely neat.
I got annoyed by Xiaomi's MIUI Android skin for always killing my apps in the background after several minutes of not using them ....
Hi Gary.,
I have seen the same app, in the same conditions in foreground (so no background tasks) on two different android devices that I have requiring very different amount of RAM, at least according to android's task manager. We are not talking about games here, where the tier of the device could make a difference, but productivity apps.
Could it be that some apps adjust their memory requirements based on the amount of free ram? Say I have a 12gb phone, Google photos might have no problem loading some off-screen thumbnails in memory
Java uses garbage collections to free unused memory. Basically, it periodically scans all variables in a program and frees memory for unused ones. This process requires CPU, so whenever it cans (ie you have a lot of RAM), it will try to run it as rarely as possible, to maximize performance. This is why apps typically consumes more memory if you have a lot of RAM on your device.
I'm pretty sure you've said before iOS actually pauses an instance of an app when you swipe away from it and it does more compression while in the ram than Android because it's garbage collection is not that efficient compared to iOS.
The thing I could understand that, there's always a tradeoff, you want your device to be most efficient then you're losing accessibility because you have to optimize for that specific set of hardware, you're kinda locked or you're losing efficiency for accessibility, whatever hardware it is it will run anyway.
Excellent.....
Best explanation.... 👌
Glad you liked it
Superb Sir!!!👌👌👌 PLEASE MAKE COMPARISON VIDEO OF BATTERY CONSUMPTION BETWEEN ANDROID AND IOS.
A general battery comparison video isn't possible there are just too many factors. There are so many different Android devices with different battery sizes, processors, screens, etc. Just not possible.
I’m curious about how cross platform apps compare in terms of size and memory i.e flutter, React Native etc
From my experience so far, I notice that apps made specifically for iOS tend to run better without warning my phone up or draining my battery while cross platform apps are usually a tossup. Once again just my experience since I’ll never be able to run every app out there.
We need a video about the speed of the devices. Also what about the Purism- Librem devices?
I have loads of videos about the performance of these devices. I guess you are new here... Welcome... You should also check out my Speed Test G UA-cam channel.
Just how you did speed test G I would appreciate seeing what phones on the market are so aggressive with killing apps to not utilize available ram in favour of swap memory..why do this? Is it a power saving tactic?
Epic video :)
Great video Gary !
Question: If Java based implementation takes more memory, why can't Android switch to something similar to iOS to reduce the memory usage. People in many countries use android more than iOS and lot of them have very less memory. Switching to less memory option will make all these smaller android phones look/run faster and remove the perception of less optimized phones and less lag/stutter. Is this in works (like fuchsia) or is Android too big to move away from Java?
u missed the part where gary explains why java is great
Easier for programmers. Less things to learn.
Memory is cheap those days, no reason to distract this environment. Before 2012 was a problem.
Android AFAIK is about a decade old, switching suddenly to another programming language will take a tremendous amount of work and money. Imagine all apps on play store being rewritten into something like Go or Rust, and all phone companies (Samsung, Xiaomi, Asus, Oppo, etc.) switching their own build of Android into another programming language. It ain't gonna happen anytime soon
programmers on native languages needs to write more lines for memory management unlike in JAVA.
would you please make a video on rust and how it can affect topics like these?
for example:
- what do you think if we rewrite stuff on rust is it true that rust will just magically make everything faster what if swift runs on rust runtime, not obj-c ? for example
also is it possible for devs to compile directly to ARM assembly maybe in the future can languages do that is there's a way to ship the code with the machine language so less compiling is indeed is that even possible?
Even when playing big games it's really no problem for smaller RAM machines. It's just a few seconds, you probably won't notice it at all.
Hey gary can u make one video on windows vs mac ram management
Excellent video. One question, how come games can be written natively and apps cannot on Android?
The official way to write Android apps is using Java/Kotlin. However you can also write native apps using toolkits like Flutter. Since Flutter is cross-platform and from Google then it is a good way to write native Android and iOS apps using one code base.
Since each different processor requires its own unique Java Virtual Machine anyway, why not just have a Java compiler for each different processor that generates native code directly ? The high-level Java code would still be the same in both cases, so what's the benefit of the JVM ?
The JVM is faster than compiler+native run
That's kinda what the JVM will do anywy with JIT. It takes the bytecode and compiles it to native machine code on the fly (just-in-time) for execution.
Talking about the HotSpot JVM here, it usually does that after a given piece of code has been executed a few times, because doing that for every piece of code is expensive and doing that for a method that one runs once, for example, is not needed.
AOT compilation for Java and also compilers/frameworks that generate native machine executables (think GraalVM) do exist, but they have their caveats too.
One advantage of JIT compilation is being able to optimize the JIT-compiled code to the machine you're running it on, without function multi-versioning and other things that can be used in traditional compilers.
Other benefits is not having to embed the code for the garbage collector into every binary, for example.
That's what Golang does, IIRC. Every Go-compiled program has a copy of the garbage collector inside it.
See i give you Proper answer. You can make native Compiled 1-1 apps for both processors and will run smooth on both of em. Now make 100000 apps. Or SHIFT them to another processor. here you dont have to worry about transferring 100000 apps to another architecture. Male make a good JVM it runs. JAVA IS SECURE AND PORTABLE.
Unfortunately, if a system is capable of doing the same work over the same period as the other one while requiring less resources, then that system is certainly a more optimal solution. In cars this would be like a normal hatchback vs crossover SUV on a similar platform, the suspension for the SUV is always going to be a bit more complex and thus expensive because the SUV has higher centre of gravity (it's top heavy), it needs more to maintain the same stability as standard hatchback.
So the people shouting optimization on iOS are not totally wrong even though they are not getting technical reasons correct. I use and like both systems by the way so I'm not taking sides here. I also use Linux and Windows, I use each system for what my workflow requires at the time.
I think both solutions are tackling different situations. In the case of iOS, because Apple has total control over the hardware, and the hardware is limited to a very small selection of devices, they can afford to focus their efforts on compiling to native code that can be efficiently run in their platform. Android meanwhile exists in many different versions across thousands of different devices (different chips, different screens, different cameras, you know what I mean), so using something portable like Java is very smart to try to run it everywhere. So it's not less efficient for their use case: they efficiently fix the issue, making apps available throughout their fragmented Android versions.
Also, I don't particularly like either iOS or Android either, I'm just voicing my thoughts on this subject. I personally run Linux on my desktop and I wish I could do away with phones entirely lol.
Gary please make Video comparing the differents level of multitasking android ios and desktop can handle in software level I mean comparing
What Os manage multitasking more efficient
Desktop Os an android are only one with background processes running
I’m not so concerned about memory usage as I am performance. There’s just some stuff that isn’t possible with an interpreted environment, even for non-games.
It is posible to do a speedtest g with app that consume the same amount on ram in both os I mean if twitter consume 300mb replace it with another android app that use the same 300mb will be insteresting to see how ram managements works in real life if is there's an optimization thing exists
+Gary Explains I have a particular app that my Galaxy Z Fold2 just absolutely refuses to keep it RAM, called 'Taimi'. The only way I can keep it in RAM is if I force it to by pinning the app in RAM. Why with a phone with so much RAM refuses to keep an app In RAM. I have caught this app taking up as high as 400MBs of RAM.
Yeah some apps refuse to be in RAM
@@someoneyouneverknow7529 I don't know if it's the app, or the phone itself being to aggressive.
You can go to settings then apps, then your particular app, then memory, then select unrestricted for
Why wouldn’t google push for arm native apps on android?
13:45 I wanna try Ginseng Impact
How about power consumption difference between iPhone and Android?
What does it mean that they are bigger in memory on Android? Is it that they just stay in that memory or only when they are launched and in use?
iPhone 6 with 1 gig and larger screen was a issue, on top of bendgate.
Tis is such an informative video. I am surely going to share this with my friends and peers. People should know this information. Thanks a lot for this video.
Tech made easy by Prof Gary
Could it be compared to spoken languages? iPhones only communicate using e.g. Chinese, thus all apps must be compiled using Chinese. Android phones also natively speak Chinese, but has a translator (Java) so that different languages can be used for convenience, but the translator needs to translate into Chinese for the phone to understand. Correct?
I think this is a good comparison. The translation layer helps make Android apps more portable, but that also means extra work translating as you use it (JIT/interpreter), translating in advance (AOT), and always you still need the translation books on hand which requires more storage (Java/JVM).
The RAM and GPU and Cellular in iOS and MacOS will use Less Code , work in SaC. In killer Startegy in iPhone 14. Even with invesible Blocks of Codes in great idea for 50% improve GPU with more Vattery with Best Teams and Execs that report Daily to Craig and , and to Tim even in AirPods and Apple Glass, for more Battery. Also in Tesla.
Quick question does more Ram consume more power??
*GARY!!!*
Good Morning Professor!
Good Morning Fellow Classmates!
Stay safe out there everyone!
MARK!!!
Even if Android uses bigger MB on Ram usage. Still I like Androids way of Keep the App Loaded in the MEM. I HATE that Keep Closing/Killing the App. Apple is so Annoying regarding that. does it “Almost” right away.
Why Android chose to use the JVM for such a low powered system still confuses me to this day. The tight integration with the Android APIs take away lots of the portability that you usually get when you use something like the Swing API. Very puzzling.
Android apps (games) closing too fast
iOS never closes the app is there any solution
Andoid should do something about the ram management
What is wrong with Android's RAM management. Did you watch my other two videos on this subject?
So the good job that apple do is to make all as efitient as possible avoiding unnesesary procceses like this intermediate java translator. And all of that is reach by hardware and software engeniering that allow then to build a CPU that can run the code natibly as you said.
They really need to fix apps refreshing. I can use a phone with 8 gigs of ram or 12. Apps still refresh, which is very annoying. They really need to optimize the operating system it's self so it better utilizes and benefits from more ram. A 12 gig or even 16 gig phone apps should not refresh nearly as much as 8 gigs. Android.
What's you're daily driver?
I think you made a mistake at 07:10. According to your comparison at 05:40, 6G of iOS is not 8G (x0.5) on android but equivalent from 12G (x2) to 24G (x4).
The conversation about RAM in 2022 I think it's out of topic. It was a good subject when devices had 1-2G RAM. Nowdays it's not a problem to be analyzed.
I thought that SWIFT was bloatware like Java. It's a surprise to me that it has lower demands on memory.
My iOS has 2G of RAM and runs fine. 1G RAM is a problem for iOS from 2019 but still usable if you have patience.
What improvement can be made to android os without necessarily a total rebuild if there is any? Or are we stuck with this since it's like the foundation of android
Unless Java is removed, nothing can be done.
The foundation of android is Linux so kinda not much to do at this point lol.
@@GaryExplains is kotlin any better or can it be better in the future?
can oracle rewrite some stuff in rust and is that even helpful ?
Java and Linux aren't tied together and Android's RAM usage has nothing to do with Linux.
Kotlin just compiles to Bytecode the same as Java.
I don't know if you can safely make a direct comparison between the two, as both operating systems use available RAM in very different ways. For example, iOS uses memory compression for all the apps running on the system and android apps, by design of the OS, may end up using different amounts of memory on different device configurations (harware SKUs and android versions).
We can safely make any comparison we need to because a) I tested several different Android devices b) this is about user experience, so it is irrelevant if things are slightly different, the result is what matter c) Android uses compression for all the apps running the system as well d) Android tends to use more compression than iOS.
@@GaryExplains I didn't mean to question your testing methodology (sorry if it came out as such), all I'm saying is that yes, while Android apps report more memory usage, it's entirely possible that you may have the same exact user experience between two devices with 6GB ram, one running android and one running iOS. It's all about how the OS uses memory and not that one OS "needs" more memory than the other.
I am talking about how the OS uses the memory.
but but "optimisation "
And then comes custom UI on android taking up 3GB of memory in android.
U didnt talk about battery management and which OS consumes more battery
That is because this video is about RAM not battery.