ARC-aware UIImage from UIView
===

My application iterates through a directory of PDF-files, draws there first page into a off-screen UIView subclass using the CGPDF API functions, which makes a UIImage available to the application. The UIView subclass simply adds the *@property (nonatomic,assign) image*, which in its setter uses the standard way to get a UIImage from a UIView, as per Apple references.

    -(UIImage*)image {
        
        image = nil;
        
    	if( [self.layer respondsToSelector:@selector(setShouldRasterize:)])
    		UIGraphicsBeginImageContextWithOptions( self.bounds.size, NO, self.contentScaleFactor );
    	else
    		UIGraphicsBeginImageContext(self.bounds.size);
    	
    	[self.layer renderInContext:UIGraphicsGetCurrentContext()];
    	image = UIGraphicsGetImageFromCurrentImageContext();
    	UIGraphicsEndImageContext();
        
    	return image;
    }

So far, so good. My application uses ARC (automatic reference counting) and crashes in this method, short after memory warnings are received. There is no exception thrown, instruments was not of great help as I could not observe memory accumulations. Only removing the code from the setter saves the app from crashing.

I have read a lot about bridging, which seems not applicable in my case. It seems to me that the code above allocates objects and never frees them, at least that will explain the memory warnings.

Any help is appreciated.