アプリを Instruments で分析すると、CGContextDrawPDFPage によって割り当てられたデータがすぐに解放されないことがわかりました。私のプログラムは多くの「メモリ警告」を受け取るので、できるだけ多くのメモリを解放したいのですが、このメモリを解放する方法がわかりません。
http://twitpic.com/473e89/fullでわかるように、このコードに関連しているようです
-(void)drawLayer:(CALayer*)layer inContext:(CGContextRef)ctx{
NSAutoreleasePool * tiledViewPool = [[NSAutoreleasePool alloc] init];
CGContextSetRGBFillColor(ctx, 1.0, 1.0, 1.0, 1.0);
CGContextFillRect(ctx, CGContextGetClipBoundingBox(ctx));
CGAffineTransform pdfTransform = CGPDFPageGetDrawingTransform([self.superview.superview getPage],kCGPDFMediaBox,tiledLayer.bounds, 0, true);
CGContextSaveGState (ctx);
CGContextTranslateCTM(ctx, 0.0, tiledLayer.bounds.size.height);
CGContextScaleCTM(ctx, 1.0, -1.0);
CGContextConcatCTM (ctx, pdfTransform);
CGContextClipToRect (ctx, CGPDFPageGetBoxRect([self.superview.superview getPage],kCGPDFMediaBox));
CGContextSetInterpolationQuality(ctx, kCGInterpolationHigh);
CGContextSetRenderingIntent(ctx, kCGRenderingIntentDefault);
CGContextDrawPDFPage(ctx,[self.superview.superview getPage]);
CGContextRestoreGState (ctx);
UIGraphicsEndPDFContext();
[tiledViewPool drain];
}
私はすでに AutoReleasePool をラップしようとしましたが、これは何の影響もないようです。スクリーンショットは、TiledView (メソッドが属するビュー) の割り当てが解除された後に取得されます。
誰かがメモリ使用量を減らすのを手伝ってくれることを願っています。