最大线程限制? [英] Maximum thread limit?

查看:103
本文介绍了最大线程限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在哪里可以找到有关iPhone应用程序允许的最大线程数的文档,以及您对线程性能的体验?

Where can I find documentation on the maximum number of threads allowed in an iPhone application, and what are your experiences with thread performance?

谢谢!

推荐答案

Mac开发中心的这个页面为您提供线程分配成本,您可以从中估算猜测:

This page on the Mac Dev Center gives you thread allocation costs, which you can make an estimated guess from:

1kb内核成本

iPhone上的1mb堆栈空间

创建时间90微秒

1kb kernel cost
1mb stack space on iPhone
Creation time 90 microseconds

该指南建议你要求操作系统分配你的应用程序50mb的128mb ram如果你产生50个线程:

The guide suggests you will be asking the OS to allocate your app 50mb of 128mb of ram if you spawn 50 threads:


在线程
创建时,你的进程空间中为这个内存空间预留了
,但与该内存关联的实际页面
不是
创建的你他们是需要的

The space for this memory is set aside in your process space at thread creation time, but the actual pages associated with that memory are not created until they are needed

这看起来很大 - 而且这篇博客文章详细说明如果你试图使用超过46mb的ram,你的应用程序将会冻结,然后在5-10秒之后被OS杀死。

That seems like a large amount - and this blog post goes in some detail in saying that if you're trying to use over 46mb of ram your app will freeze, and then be killed 5-10 seconds later by the OS.

所以15-20个线程确实是一个安全的数量,但当然这取决于每个线程在其执行的操作中消耗了多少内存,以及还有线程完成的速度。线程完成后,内存将被释放。

So really 15-20 threads is a safe amount to stick to, but of course that depends on how much memory each thread is consuming in the operations it performs, and also how fast the thread completes. The memory is deallocated once the thread finishes.

这篇关于最大线程限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆