When I analyze my application using tools, I found out that the data allocated by CGContextDrawPDFPage will not be sent immediately. Since my program receives many βmemory warningsβ, I would like to free as much memory as possible, but I do not know how to free this memory.
As you can see at http://twitpic.com/473e89/full , this looks like this code
-(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]; }
I already tried to wrap AutoReleasePool around it, but this does not seem to have any effect. A screenshot is taken after the TiledView (the view the method belongs to) is released.
I hope someone can help me reduce memory usage.
source share