iphone – __NSAutoreleaseNoPool():类General的对象0x753c2f0自动释放,没有池到位 – 只是泄漏

iphone – __NSAutoreleaseNoPool():类General的对象0x753c2f0自动释放,没有池到位 – 只是泄漏,第1张

概述我有一段时间没有注意到我的控制台输出,我突然发现很多奇怪的错误. __NSAutoreleaseNoPool():对象0x753c2f0类通用自动释放没有池到位 – 只是泄漏 __NSAutoreleaseNoPool():类__NSArrayM的对象0x753c300自动释放,没有池到位 – 只是泄漏 我不知道这发生了什么? 编辑.. 我用这个 [self performSelectorInBa 我有一段时间没有注意到我的控制台输出,我突然发现很多奇怪的错误.

__NSautoreleasenopool():对象0x753c2f0类通用自动释放没有池到位 – 只是泄漏

__NSautoreleasenopool():类__NSArrayM的对象0x753c300自动释放,没有池到位 – 只是泄漏

我不知道这发生了什么?

编辑..

我用这个

[self performSelectorInBackground:@selector(startupStuff) withObject:sender];

使用statupStuff,我有这个

General *rdb = [[General alloc] autorelease];[rdb refreshDBData];

错误发生在refreshDBData方法中的代码之后不久.

解决方法 自动释放池与线程相关联.如果通过performSelectorInBackground创建线程,则需要为自己创建和销毁自动释放池.所以你需要startupStuff看起来像这样:

- (voID)startupStuff:(ID)sender{    NSautoreleasePool *pool = [[NSautoreleasePool alloc] init];    // ... everything else you were doing ...    [pool drain]; //see comment below}

另外:Richard下面指出排水是优先释放以承认(在桌面上,还没有在iOS上)你可能正在运行垃圾收集器. Apple的特定词是(source):

In a garbage-collected environment,sending a drain message to a pool triggers garbage collection if necessary; release,however,is a no-op. In a reference-counted environment,drain has the same effect as release. Typically,therefore,you should use drain instead of release.

所以我纠正了我的例子.可以说,这个具体问题与iPhone有关,目前该设备上没有垃圾收集.因此,原始海报在“排水与释放效果相同”的阵营中,而不是“排水……如有必要,则触发垃圾收集;然而,释放是一个无 *** 作”阵营.

总结

以上是内存溢出为你收集整理的iphone – __NSAutoreleaseNoPool():类General的对象0x753c2f0自动释放,没有池到位 – 只是泄漏全部内容,希望文章能够帮你解决iphone – __NSAutoreleaseNoPool():类General的对象0x753c2f0自动释放,没有池到位 – 只是泄漏所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/web/1054216.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存