のようなコールバックでスレッドを作成した場合。
NSAutoreleasePool* pool = [NSAutoreleasePool alloc] init];
while(1) {
//Process Stuff
}
[pool release];
プールが空になることはないので、自動リリースされたものが実際に解放されることはないと思います。私は次のように物事を変えることができます:
while(1) {
NSAutoreleasePool* pool = [NSAutoreleasePool alloc] init];
//Process Stuff
[pool release];
}
しかし、頻繁に割り当て/削除するのは少し無駄に思えます。メモリのブロックを取っておき、プールがいっぱいになったら解放する方法はありますか?