Снимок экрана «Профилирование утечек в инструментах»: http://i.stack.imgur.com/rthhI.png
Я обнаружил, что мои объекты UIImage протекают с помощью инструмента Инструменты.
Согласно документации Apple, объект, возвращаемый из UIGraphicsGetImageFromCurrentImageContext, должен иметь значение autoreleased , я также вижу событие «Autorelease» при профилировании (см. Первые 2 строки истории моего прикрепленного снимка экрана). Однако, похоже, что событие «autorelease» не действует. Почему?
EDIT:
Код прикреплен, я использую приведенный ниже код для «смешивания» двух UIImages, также, позже, я использую UIMutableDictionary для кэширования этих UIImage I, «смешанных». И я совершенно уверен, что я вызвал [UIMutableDictionary removeAllObjects], чтобы очистить кеш, поэтому эти UIImages «должны быть очищены»
+ (UIImage*) mixUIImage:(UIImage*)i1 :(UIImage*)i2 :(CGPoint)i1Offset :(CGPoint)i2Offset{
CGFloat width , height;
if (i1) {
width = i1.size.width;
height = i1.size.height;
}else if(i2){
width = i2.size.width;
height = i2.size.height;
}else{
width = 1;
height = 1;
}
// create a new bitmap image context
//
UIGraphicsBeginImageContextWithOptions(CGSizeMake(width, height), NO, i1.scale);
// get context
//
CGContextRef context = UIGraphicsGetCurrentContext();
// push context to make it current
// (need to do this manually because we are not drawing in a UIView)
//
UIGraphicsPushContext(context);
// drawing code comes here- look at CGContext reference
// for available operations
//
// this example draws the inputImage into the context
//
[i2 drawInRect:CGRectMake(i2Offset.x, i2Offset.y, width, height)];
[i1 drawInRect:CGRectMake(i1Offset.x, i1Offset.y, width, height)];
// pop context
//
UIGraphicsPopContext();
// get a UIImage from the image context- enjoy!!!
//
UIImage *outputImage = UIGraphicsGetImageFromCurrentImageContext();
// clean up drawing environment
//
UIGraphicsEndImageContext();
return outputImage;
}