NSAutoreleasepool: Memory Management problem in iPhone app

629 views Asked by At
__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.

2

There are 2 answers

2
itZme On BEST ANSWER

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];
2
Kazuki Sakamoto On

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.