The autoreleased objects are probably the reason for the increasing memory usage,
but you cannot use NSAutoreleasePool
with ARC. Replace
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// ...
[pool drain];
with
@autoreleasepool {
// ...
}
Update: You actually need two autorelease pools in your case. First of all, the Threading Programming Guide states:
If your application uses the managed memory model, creating an autorelease pool should be the first thing you do in your thread entry routine. Similarly, destroying this autorelease pool should be the last thing you do in your thread. This pool ensures that autoreleased objects are caught, although it does not release them until the thread itself exits.
And the last sentence gives the clue why you need another autorelease pool: Otherwise all autoreleased objects created in the long-running loop would only be released when the thread exits. So you have
- (void)myThreadMainRoutine {
@autoreleasepool {
// stuff inits here ...
while (_live) {
@autoreleasepool {
// do some stuff ...
[runLoop runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.05]];
[NSThread sleepForTimeInterval:0.05f];
}
}
// clean stuff here ...
}
}