UISegmentedControl with tintColor leaks CGImage/UIResizebleImage

Originator:max.v.stepanov
Number:rdar://12597277 Date Originated:29-Oct-2012 09:05 PM
Status:Open Resolved:
Product:iPhone SDK Product Version:6.0
Classification:bug Reproducible:yes
 
Summary:
Creating and deallocating UISegmentedControl (e.g by navigating back and forth to a view controller) which has style=Bar, tintColor set and only segments with titles added leaks CGImage/UiResizeableImage over time. This is notable with Instruments.

Steps to Reproduce:
Run an app with the sample code below.
//code
segmentedControl=[[UISegmentedControl alloc] initWithFrame:rect];
[segmentedControl setSegmentedControlStyle:UISegmentedControlStyleBar];
[segmentedControl setTintColor:[UIColor redColor]];
[segmentedControl insertSegmentWithTitle:@"Button 1" atIndex:0 animated:NO];
[segmentedControl insertSegmentWithTitle:@"Button 2" atIndex:1 animated:NO];
//end of code

Expected Results:
Number of live CGImage/UiResizeableImage instances should remain the same as new UISegmentedControl instances allocated/deallocated.

Actual Results:
Number of live CGImage/UiResizeableImage instances increases over time.

Regression:
Works fine in iOS 5.1

Notes:
Also works as expected (no leaks) when tintColor is not set.

Comments

I've just run into this on iOS 6.1. I didn't notice it when the segmented control was added to a navigation bar as the titleView of a navigation item, but when I add it directly as a subview I see this problem.

By percysnoodle at April 23, 2013, 6:38 a.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!