当我使用Instruments分析我的应用程序时,我发现CGContextDrawPDFPage分配的数据不会立即释放。由于我的程序收到很多“内存警告”,我想释放尽可能多的内存,但我不知道如何释放这些内存。取消分配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(方法所属的视图)被释放之后拍摄屏幕截图。
我希望有人能帮助我减少内存使用量。