Xミリ秒ごとに無限の量のスクリーンショットを撮り、それらをイメージビューに表示する小さなアプリでメモリの問題が発生します。自動リリースを使用しても、メモリがすぐにいっぱいになります。コードは次のとおりです。
- (void)draw {
do {
@autoreleasepool {
CGImageRef image1 = CGDisplayCreateImage(kCGDirectMainDisplay);
NSBitmapImageRep *bitmapRep = [[NSBitmapImageRep alloc] initWithCGImage:image1];
NSImage *image = [[NSImage alloc] init];
[image addRepresentation:bitmapRep];
_imageView.image = image;
[NSThread sleepForTimeInterval:1];
}
}while(true);
}
何か案は?