简体   繁体   English

在单个iPhone应用程序中可以设置的NSTimer的最大数量

[英]Maximum number of NSTimer that can be set in Single iPhone Application

I am currently developing one application, in which my client wants to have some functionality in which i need to start lots of timer for different functionalities. 我目前正在开发一个应用程序,其中我的客户希望具有一些功能,在该功能中我需要启动许多用于不同功能的计时器。

So, my question is that, by setting lots of NSTimer in single app, will it lead my App to crash?, or Is there any much side effect in application's performance? 因此,我的问题是,通过在单个应用程序中设置大量NSTimer,它会导致我的应用程序崩溃吗?还是在应用程序性能方面有很多副作用?

Internally, NSTimers are all implemented on a single hardware timer. 在内部,NSTimers都在单个硬件计时器上实现。 The OS keeps a central list of timers for all running apps and simply scheduels a single hardware timer for the soonest event. 操作系统会为所有正在运行的应用程序保留一个集中的计时器列表,并为单个事件安排一个硬件计时器。

Adding timers does not change the behaviour of your app. 添加计时器不会更改应用程序的行为。 That said, in the same way that adding thready to an essentially single process machine makes runtime management easier, adding timers can help you partition your problem. 就是说,就像在本质上为单个进程计算机中添加线程可以简化运行时管理一样,添加计时器可以帮助您对问题进行分区。

Number of timers isn't a problem. 计时器数量不是问题。

NSTimers do consume battery depending on what is running in each timer loop and how many times it is running. NSTimers确实会消耗电池,具体取决于每个计时器循环中正在运行的内容以及其运行了多少次。 Again, performance varies form device to device, as iPhone 6 has better RAM and memory then iPhone 5. So, might give memory warning and crash for certain devices. 同样,性能因设备而异,因为iPhone 6具有比iPhone 5更好的RAM和内存。因此,可能会发出内存警告并导致某些设备崩溃。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM