ipap应用程序的mmap错误与线程和核心数据 [英] mmap error on ipad app with threading and core data

查看:139
本文介绍了ipap应用程序的mmap错误与线程和核心数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用核心数据实现了我的项目,但是,每当我试图调用保存到NSManagedObjectContext时,应用程序运行很长时间,类似这样出现:

I've had my project implemented with core data, however, whenever I tried to call save to a NSManagedObjectContext, the application goes on running for a long time and something like this appears:

Call(51871,0xb03e6000) malloc: *** mmap(size=2097152) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
Call(51871,0xb03e6000) malloc: *** mmap(size=2097152) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
Call(51871,0xb03e6000) malloc: *** mmap(size=2097152) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug

我的应用程序在发生这种情况时运行12个线程。这可能是因为内存泄漏?

My app runs 12 threads at the time this happens. Is this possibly because of a memory leak?

推荐答案


发生。这是可能的
因为内存泄漏吗?

My app runs 12 threads at the time this happens. Is this possibly because of a memory leak?

你正在运行的线程是不相关的•)。是的,这是最可能是由于内存泄漏,或至少,滥用内存。

That you are running threads is irrelevant (except that it isn't•). And, yes, this is most likely due to a memory leak or, at the least, abuse of memory.

它不会占用非常多的2,097,152字节分配给你以耗尽所有可用的内存。它可能不是泄漏;如果你只是有一个长时间运行的过程,在清理之前积累了大量的内存,这可能会导致这种行为。

It won't take very many 2,097,152 byte allocations for you to exhaust all available memory. And it may not be leaks; if you simply have a long running process that accretes lots of memory before cleaning up at the end, that can cause this behavior.

不知道更多,很难说出发生了什么。当然,按照指示设置断点,并查看发生失败的分配的位置会很有趣。

Without knowing more, it is very hard to say what is going on. Certainly, setting a breakpoint as instructed and seeing where the failed allocation is occurring would be interesting.

•12个线程在iPhone应用程序中的可怕很多。只有一个核心(2,如果在iPad 2上),内存I / O带宽不是那么好,因此,12个线程竞争资源很可能会比两个线程慢很多。

• 12 threads is an awful lot in an iPhone app. There is only one core (2 if on an iPad 2), memory I/O bandwidth isn't that great, and, thus, 12 threads competing for resources are very likely going to run a heck of lot slower than a couple of threads.

此外,你不应该产生线程(在极少数情况下)。你应该使用队列(GCD或NSOperationQueue),因为它们更好地与操作系统集成。

Furthermore, you shouldn't be spawning threads at all (outside of rare circumstances). You should be using queues (GCD or NSOperationQueue) instead as they are far better integrated with the OS.

这篇关于ipap应用程序的mmap错误与线程和核心数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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