Memory management, which is poisoned by the release of memory-accelerated systems under Windows, people mistakenly assume that the more memory is left, the better. In fact, when an application exits, the OS should not immediately release its memory, but wait until the memory is insufficient to start releasing. Why?
(1) Some applications start off frequently, and if the program is loaded into memory at startup, the boot speed will be very fast. Conversely, if it is not in memory, it needs to be read from the external storage, waiting, slower.
(2) The higher the memory utilization, the better. Memory is a volatile storage device, and when power is lost, the data disappears, and it needs to be refreshed constantly. Refresh 0, or 1, for power is not a big impact, so there will not exist, low memory usage, saving electricity of the argument. Memory is to take the CPU needed to save the program and data, the higher the use of the better.
again, Android and iOS systems, Both of these are good mobile device operating systems.
Android Memory Management:
Android System architecture diagram
Android uses the Linux kernel kernel to manage operating hardware, integrates various libraries, builds applications on VMS (virtual machines), and each app runs a standalone VM that is designed to avoid an app crash that prevents the entire system from running. Each app opens a VM, which of course consumes a lot of memory. Physical memory is limited, so you must think of ways to collect memory. " Detailed introduction to Java garbage collection mechanism" Here is a blog post that was previously reproduced in GC. The GC mechanism of Java can be used directly inside the VM, but not enough, because there are many apps that open up a lot of VMS, which requires a strategy to release some VMS or release onstop/onpause activity. Finally, the point to note is that the size of the VM is not unlimited, there is a setting in the/system/build.pro file: Vm.heepsize=??? M,vm.heapgrowthlimit=??? M.
iOS Memory management:
iOS is a Unix-like operating system that uses OBJECTIVE-C programming and is up-to-date with swift programming. Compared to the Java language used by Android, the iOS programming language is more controllable, more inclined to the bottom, and therefore more efficient to implement, but also relatively difficult to develop. The system-level programming language and the focus on the user experience provide iOS with a very fluid experience. iOS can also complete GC by reference counting, but it is far from the GC mechanism of Java. Based on Darwin, Darwin is the core of the Mac OS X operating system and is a mackernel built on a core architecture that combines the Mach kernel with the FreeBSD two set of programs. Because the underlying base is similar, memory management on iOS is similar to OS X, which is the same way that the Mac OS X system manages memory and may be weaker. There's no way to understand it. As with Windows, the memory management of Windows is very bad, and often some memory is not recycled, causing memory exhaustion and having to restart the machine. Anyone who has used Mac OS X can feel that OS x is extremely fluid, thanks to its excellent memory management system.
iOS system architecture diagram
What is the main reason why Android uses more memory than iOS?
There are many reasons for the Android app to occupy a lot of memory, mainly because: Android allows multi-task background to run, Android app developer to enhance the background residency, resulting in a large number of apps occupy memory can not be released. This problem on iOS will not appear, in addition to bring the program, music programs run background playback, positioning software, and other have no background resident rights, but run the app push message to the user, so that the chat tool to alleviate the online problem.
After you press the home key, iOS only saves one exit, which is why a series of thumbnails appear when you double-click the Home button. Instead of rushing to release unused apps, freeing up memory should be done by the OS, and the OS will release unused apps and store useful data when memory is scarce.
Under Android, the memory used by a single app is limited by the heapsize,heapsize of the VM, and the longer it takes to get GC on the VM at a time. The system cannot reclaim unused app memory due to the presence of a large number of resident memory programs in the Android system. In order to ensure that their app can have enough memory to run, developer will first request enough memory, increase the heapstartsize, heap allocation of the initial size, increase the memory ram consumption, the key is to elevate the permissions for the background resident. This makes the app memory not recyclable, but users always open new apps, what to do? In fact, when the app takes up more memory, it will trigger the GC and the adjustment strategy, can reclaim some memory, but it is not enough, so it recycles onstop/onpause activity. It is important to note that the time of the GC increases with the heap, which is a vicious cycle.
Developer apply enough memory for fluency-> heap Increase-> Insufficient memory-background resident activity cannot be freed-> heap increases, GC time grows
-> CPU-> Performance Degradation-> boost configuration, increase memory, high-frequency multicore CPU-> developer request enough memory for fluency- ...
PS: As if to see the Wintel Alliance, you are responsible for upgrading the hardware configuration, I am responsible for the consumption of surplus resources, forcing users to upgrade again, you sell hardware to make money, I sell software to make money, probably the market is to cultivate it
Why the Android system has larger memory than iOS