about multitasking and memory management for iOS
see a lot of people for their available memory is 350MB or 380MB tangled. In order to optimize a little bit of available memory cost brains.
The task management and memory management of iOS is very different from that of Windows. Many people are accustomed to using
thinking of Windows to look at iOS.
windows Everyone knows that the more windows open, the slower the system, and why? Because all windows are running, CPU usage is high, and all the memory is accounted for. Insufficient memory also forces the system to use the hard disk to act as virtual memory, and the hard disk reads and writes will of course consume more power and drive slower.
iOS is different. First of all, iOS background tasks, in addition to very few can run in the background (such as music playback), the vast majority of the background is suspended. For example, need for speed, cut to the background after the motor Roar no, switch back after the point "continue" to continue to run. This kind of software allows it to continue running in the background in addition to the increase in power consumption, there is no point. You don't want a racer to go on the rampage while cutting into the background?
since the software hangs in the background, of course it does not occupy the CPU, it will not power consumption.
The software hangs in the background, does not occupy the CPU, but always should occupy the memory? Do you consume more memory? Will it slow down the system
?
The answer is still: No.
iOS does not have virtual memory ready for IPA. If the foreground software is not enough, iOS will directly release the memory used by the background software, and will not use hard disk virtual memory like Windows (causing power consumption to increase). And the release of a piece of memory is simple, that is, a memory block of a flag from "Occupy" to "idle", the contents of the memory is discarded without switching to flash memory, fast.
As you can see , our experience using Windows is not applicable to iOS.
release the backend which software memory also has fastidious.
Some background software will be released after the serious consequences, such as game software, the software is released after the end of the switch back is equal to start again, the game progress is lost.
some software is irrelevant. For example, e-book software, reserved Memory is released, the software can only keep a bookmark, switch back to reload the content, continue to read. For example, Sarafi browser, the occupied memory is released, switch back is nothing more than a page reload, will not cause serious consequences.
iOS gives priority to releasing background software that is not memory-sensitive.
for software that has switched to the background, which does not account for both CPU and memory, the software is actually over, and the backend software is more unlikely to consume power. Double-click Home to see the list of background tasks, most of which are such software.
saying so much, that means: iOS can open software without deliberately to end it.
in fact, the iOS software doesn't even have an exit function, so that some people complain that Apple iOS design is not human-friendly? To quit a software, you have to double-click Home, and then long press the icon below, the icon jitter and then press the fork, the trouble is dead. In fact, look at the front to know that the iOS software does not need to quit.
in fact, the goal of Apple iOS multitasking is to let you forget about multitasking, like iOS
3.x of a single task to use multi-tasking, want to run which software run it, do not want to run directly to the home, regardless of how many software in the background, will not slow down the foreground software (this is, the background is suspended state does not account for the CPU). This is unthinkable for windows, but Apple does.
not Windows is incompetent, but because Windows is used for work and needs to be versatile multitasking, iOS is just a mobile phone operating system with a different focus.
---
Some people in the iOS memory no-load and full power consumption of the same question, think: the memory is no-load save electricity, full load multi-consumption.
this view is wrong.
The so-called no-load and full load, is the operating system. And for the memory chip circuit, see only 0 and 1, even if the free memory unit, there are 0 and 1 in the inside, it must faithfully save all the data, iphone4 has 512MB of memory, as long as a boot, the chip must be kept power to save 512MB of data. It is not possible for the operating system to think that there is free memory, it will cut off those free memory units of electricity to save power.
take a computer, for example, you have two memory bars, and a boot of these two memory bars will have to power all. Not because you have a large amount of free memory, the motherboard loses power to one of the memory strips and then re-power it because the system needs more memory space.
Thinking that full memory will increase power consumption is still the inertia of windows. Again: The Windows system, the memory is full, the system will use the hard disk to do virtual memory, so the power consumption increases and slows down, but iOS does not use the hard disk to do virtual memory, but directly release some of the background software occupied memory, until the memory is enough to allocate.
so the memory is empty and full, and the power consumption is no different for iOS. Because the memory is released directly and its contents are discarded without saving to the hard disk (which is not the same as Windows), there is no difference in the speed of the memory load and the full load for iOS.
----
Some people do not open the background power consumption has a clear basis for the difference.
in this connection, let me say:
on the forum someone closed all backstage, closed the notice, even opened the flight mode, one night standby still did not see more than 10% of electricity. The solution is not to be baffled. There are people who do not know anything about anything is not closed, silly people have silly blessing, a night standby still 100% of the electricity.
Power consumption problem varies from person to person, cannot generalize.
as far as I am concerned, only open 2g signal standby, open the notice, deliberately leave a few large games in the background do not close, one night off 1%.
in fact, backstage game you switch back, all will be in the suspended state, all have to point on the screen resume to continue, the fact can be explained: The game is suspended in the background. A completely paused background task if you can still keep it CLP, you underestimate Apple's system designers too.
such as plant warfare zombie game, switch to the background and then switch back to the screen, see the game
paused's words? The game is completely paused in the background. Know that it won't go on until you resume.
This is true for all games that support native backgrounds.
the benefit of this multi-tasking mechanism is that it doesn't slow down the system and drives a lot of things, just as smoothly. The disadvantage of QQ can not really backstage (so there is a push notification), download tasks will be suspended and the like. But the iphone has backgrounder such powerful backstage software. Do not know wp7 on the backgrounder such software.
in fact, we used to wp7
or iphone.
found that there is no need to really backstage. QQ push to do is actually also the same.
software and the like as long as support mango backstage, switch out can pause, switch back to continue.
wp7 limit background 5 is because 256 system memory of a single application available memory limit is 90, the current machine o are 512 memory, a single available memory of 90+256, almost can run 4 applications at the same time, considering that the general application does not always occupy 90 of the memory, So running 5 at the same time is a more reasonable number.
The so-called does not affect only the general statement, the principle is that the new app request memory is not automatically clear before the program, although the automatic clear, but this is still a system of automatic judgment process
practical application sometimes can feel, especially open a big app, will flash back, and then re-enter the good
Push In fact you can understand that the mobile text messages you send, in fact, in theory is instantaneous.
One of the representatives is WP7 messenger, is the text inside the integration of that, can be 24 hours online, power consumption will not have any changes, the standby 2 days or two days, as long as you do not select offline, someone else's wp7 on the Messenger contact to see you 24 hours are online, And any time you send messages to you is like text messages that you receive instantly.
push is not what the mobile phone software to constantly refresh data, such as 30 seconds once, 1 minutes once, or two minutes once, this way, the battery can not afford, the delay is also large.
and WP7 messenger24 hours online, power a little feel, the two days or two days.
The push itself to theoretically should be instantaneous, but certainly not as long as the socket connection immediately, because the middle cause more delay.
QQ Push, the first delay link, TX server itself on the processing of the message, TX using Microsoft's push service, then the TX server and even Microsoft server may delay, finally Microsoft push message, finally the mobile phone by network connection to get the message ...
anyway is the push may delay the link a bit more, socket which like the socket directly connected to the TX server, like the previous version of QQ push is very exhausting, but the new version is much better, that is, TX improved its competence of the link.
Messenger is Microsoft's own things, the lack of some uncontrollable links, delay control is also better.
like a foreign software can do a more stable push, Microsoft's own Messenger more do not say, QQ, also need to work hard to solve the delay of the network, like we visit Live is slow, shops are convulsions, so Microsoft does not in the domestic server, this push the uncontrolled factor is more.
actually, except for the BlackBerry push, and the Find
my
phone feature, the other is not really the meaning of the push. The data is obtained via pseudo-long connection or timing, including IPHONE,WP and Android
BlackBerry is and operators have specific similar text messaging protocol, need the carrier's system support, the other is actually the client active polling. However, because the push server is unified, the number of links is reduced so as to achieve the purpose of saving electricity. Each device has a specific device ID and certificate, and the certificate is used to authenticate the data from the push server .
(Note: Ram saves data is power-hungry.) Each bit of RAM is kept as "1" to charge the circuit vacant land, otherwise the electrical leakage of the circuit will let the potential drop. )
just remember a word, the car is a lot of obstruction! Otherwise, the two-way 2 lane allocation is OK, but also to Mao 8 lanes ...
In theory, the memory is continuously powered up and the voltage is constant, so the data exchange does not generate the so-called power increase. Unlike hard drives, the energy consumption is not the same when seeking and not seeking a path. The same CPU will change in frequency and generate power changes as the load of the operation is generated. But one thing to be clear, the program itself takes up memory, only to perform part of the data, the largest memory function is pre-cache, direct and fast exchange of data. But essentially, the software opens or reads the data stored on the data card or flash memory chip, which is the equivalent of being in a seek, and the CPU must be part of the resources to preprocess it.
in the background, as long as the raw data is running on the underlying, I/O requests are being made to the required resources. The so-called system, this time just according to set logical rules to arrange I/O priority level. The CPU simply dispatches resources, executes, and operations according to logical commands.
There is a background time, not completely reject I/O requests, just according to priority allocation of resources to defer I/O requests deferred or deferred processing, so will certainly occupy some resources, just according to the system architecture and its own logical instructions of the different use of the amount of resources.
regardless of the background mechanism, as long as there is a background run, it will certainly account for resources, but the system, the hardware to each other, that is, the optimization of the good, equivalent to the scheduling mechanism is good, the same 2 lanes of the same segment can be over 10 vehicles, and the dispatch is not good can only over 5 vehicles. In the final analysis, the system is a hardware resource integration, allocation, scheduling, implementation efficiency issues. Windows multi-tasking mechanism, is really designed for the overall work, and its own system architecture and design philosophy is different, so-called compatibility more refers to all aspects of hardware, for software is more complex hardware to run, and at the same time run more software without conflicting, and there is a compromise, Good efficiency. Mac
The OS is based on what system architecture everyone should be aware of, and the previous Mac machine CPU architecture Everyone knows what is the matter? A particular system is made for a specific hardware, one on the other. So Mac
The OS can only compare with Windows. iOS can only compare with wm,wp7. iOS is really different than the previous WM, and if you're comparing windows, that's completely out of the comparison. The back-end mechanism of iOS is essentially personal and wp7, or even less efficient than wp7 in some ways. Because the background mechanism of iOS is equivalent to putting the resources required by the entire program in the background only to a terminating tag, it is possible to quickly terminate and release resources after triggering thresholds. But this kind of termination is very slick termination, iOS is equivalent to you deleted the file, that is, just put into the Recycle Bin. Need to be able to restore at any time, but you need to manually click the Recycle Bin to restore files and confirm. Files put into the Recycle Bin everybody knows it's about taking up space? That is, resources. and WP7 is more like a running task after the abort of the necessary data packaging made a snapshot and storage, note that this time is "abort." Then the step is to directly delete and empty the Recycle Bin, but the data is actually still on the hard disk, but the logical deletion, as long as not write, that is, the physical changes to fill, then this part of the number is still and recoverable. At this time the process and resources required by the program are actually released in the background. I understand the so-called Tombstone mechanism. Dig a hole, bury it, fill it up, just a tombstone to show what's going on. Do not need that nature has died, do not waste resources. If necessary, there is the original information, just like cloning, recovery is possible. The only concern is the efficiency at the time of resurrection and the correct calibration of the data. Some friends may understand, but it would be more troublesome and resource-intensive to say this? Familiarity with disk storage principles or a friend of a thin raid application should be easy to see, the data itself is a bunch of 0 and 1,raid1 or 5 is in the read and write, change the time to add tag check information, when the disk corruption recovery number of times according to this information to fully reply to the data. But one thing to be clear, this program's original packet, that is, the program after the installation of the data file itself is not deleted, so do not need to be fully logged or fully restored, just run time to generate changes and associated with the necessary data is recorded, so recovery time does not need too much fuss. QQ in iOS to do at all times to maintain the legitimacy of the request network connection, and naturally equal priority to the system to terminate the triggering threshold, it is also logical to be backstage. So like QQ such moments need to refresh the memory data and the disk data also make changes to the east, WP7 appear not tolerant. Because under the WP7, in addition to the Microsoft license can be backstage, other programs once you are backstage, you will be the representative to pack your buried, no matter what you need, what priority, the same as bury it again. Microsoft's so-called 5 allow the background of the restrictions may be to give themselves convenience ... Those Microsoft default background interface will be XX in the future, the software will be able to impersonate the real backstage. Tombstone mechanism is Microsoft windows
Phone
7 A program run rule in the mobile operating system. The simple point is that when a task is interrupted (such as a call), the system logs the status of the current application (as if the event was recorded on a tombstone) and then aborts the program. When recovery is required, the program is restored to the state before the break, based on the content on the tombstone. One such mechanism is the "tombstone mechanism" .
Edit the tombstone mechanism of this paragraph specific performance
Microsoft has released its new windows this year
Phone 7 mobile operating system, but it is puzzling that WP7 does not support multi-tasking operation. It is understood that WP7 is not a strict single task, such as WP7 in Microsoft's own IE and Zune can run at the same time.
first of all, some of the basic rules of WP7 system program run, Microsoft does not allow any third-party applications in the background of the WP7 run, only one application at a specific time in the foreground, if your application is not displayed in the foreground, it means that these programs are not running, This does not cost running memory and processor resources. This is done primarily to extend battery life and ensure a consistent user experience.
but all WP7 phones will be equipped with Back button hardware, which, in addition to the return navigation function, will also support switching between applications, such as when you click on a page link in an application and then call the built-in browser to view it. Once you have finished viewing it, you can press the back key to return to the program you just made.
Now the problem is, is the current application switching back to the previous app, did you restore an app or reopen the app? Because I have already said, WP7 does not allow the background to run the program, and the difference between the two is that the re-open will not be maintained just the use of the state, recovery can continue to use the state, this is about the Microsoft Tombstone (tombstone) mechanism.
tombstone is a processing mechanism for Microsoft to switch application state for WP7, taking the process as an example, when a user is using an application, such as a game or news reading, when a call comes in, the call prompt and the call page are displayed in the foreground, and the running game disappears. But WP7 does not allow the background to run the application, this time the tombstone mechanism will trigger, the game's running state including the screen, progress and so on data will freeze save, equivalent to pause, but the game does not run, this is also the meaning of the tombstone name: The application is dead, but the tombstone records have all the status of death. When the call is over, the game operating system restarts the application process and passes the state data to the app for recovery, which is also equivalent to crawling out of the graveyard and restoring according to the state recorded on the tombstone.
in the program code example, Microsoft gives a single application running status code, a total of four app.xaml.cs files, these directly related to the execution mode of the code is Application_
launching, Application_ activated, Application_ deactivated, Application_
closing, which are startup, Resurrection (activating the Program Recovery State), deactivating (logging tombstone data), closing (completely off). Developers need to note that in the development process requires the use of Microsoft-given tools and related code to allow their application to support the tombstone mechanism, or when the user is in use when suddenly a phone come over and then have to manually open the program again and again, which will make users very uncomfortable.
In the early WP7 system, Microsoft did not kill the process completely when the program was not running, but it paused, but it caused confusion in the background running stack, and the API and event triggers often had problems, so Microsoft decided to use the tombstone mechanism.
However, the full implementation of the tombstone mechanism will affect certain functions of the telephone, such as SMS, instant messaging, weather and other applications that need to be kept running and updated at all times, Microsoft also gives the push notification service ( push
Notification Services), which allows applications to call the interface to maintain real-time updates.
Apple iOS, with Windows Phone7, System, memory, CPU processing, and background programs running, detailed Microsoft Tombstone mechanism system