NSAutoreleasepool:iPhone应用程序中的内存管理问题

发布于 2024-10-19 09:25:30 字数 712 浏览 5 评论 0原文

__NSAutoreleaseNoPool(): Object 0x4c70ec0 of class UISegmentedControl autoreleased with no pool in place - just leaking
__NSAutoreleaseNoPool(): Object 0x4c70ec0 of class UISegmentedControl autoreleased with no pool in place - just leaking
__NSAutoreleaseNoPool(): Object 0x4c70ec0 of class UISegmentedControl autoreleased with no pool in place - just leaking
__NSAutoreleaseNoPool(): Object 0x4c70ec0 of class UISegmentedControl autoreleased with no pool in place - just leaking
__NSAutoreleaseNoPool(): Object 0x4c70ec0 of class UISegmentedControl autoreleased with no pool in place - just leaking

这是我在控制台中收到的警告。虽然它不会造成崩溃,但似乎是一些内存管理问题。

可能出什么问题了?

我还没有自动释放我的分段控件。

__NSAutoreleaseNoPool(): Object 0x4c70ec0 of class UISegmentedControl autoreleased with no pool in place - just leaking
__NSAutoreleaseNoPool(): Object 0x4c70ec0 of class UISegmentedControl autoreleased with no pool in place - just leaking
__NSAutoreleaseNoPool(): Object 0x4c70ec0 of class UISegmentedControl autoreleased with no pool in place - just leaking
__NSAutoreleaseNoPool(): Object 0x4c70ec0 of class UISegmentedControl autoreleased with no pool in place - just leaking
__NSAutoreleaseNoPool(): Object 0x4c70ec0 of class UISegmentedControl autoreleased with no pool in place - just leaking

This is what I get as warning in console. Though it doesnt create a crash but seems to be some memory management issue.

What could be wrong?

I have not autoreleased my segemented control.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甜点 2024-10-26 09:25:30

当您使用多线程时,通常会出现此问题。
如果您使用线程,应该为该线程创建自动释放池

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

//Code....

[pool release];

This problem commonly arise when you are using multi-threading.
If you using threading, should create autorelease pool for that thread

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

//Code....

[pool release];
情深如许 2024-10-26 09:25:30

如果您在非主线程的线程中使用 UISegmentedControl,如 @Martin 所说,那么它是不安全的。

UIKit 框架参考 - 简介

注意:大多数情况下,UIKit 类
应该只从一个使用
应用程序的主线程。这是
对于派生类尤其如此
来自 UIResponder 或涉及
操纵应用程序的用户
任何方式的接口。

If you are using UISegmentedControl in a thread that is not main thread as @Martin said, it is not safe.

UIKit Framework Reference - Introduction

Note: For the most part, UIKit classes
should be used only from an
application’s main thread. This is
particularly true for classes derived
from UIResponder or that involve
manipulating your application’s user
interface in any way.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文