最大线程限制?

编程入门 行业动态 更新时间:2024-10-08 22:16:01
本文介绍了最大线程限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在哪里可以找到有关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.

更多推荐

最大线程限制?

本文发布于:2023-11-12 02:02:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1580190.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:线程

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!