In order to replicate a crash I was having in my application, I had to create a sample with a slightly exaggerated repeat rate that might not be practical, but one that demo
An easy workaround for this is to replace NSString with NSAttributedString.
The crash test that @maq listed does not crash if modified like this:
-(void)threadFunc:(UIFont *)font {
@autoreleasepool {
NSString *string = @" ";
NSMutableAttributedString *test = [[NSMutableAttributedString alloc] initWithString:string];
CGRect r = {{0,0},{50,50}};
UIGraphicsBeginImageContextWithOptions(r.size, YES, 0);
for(;;) {
@autoreleasepool {
UIFont *font=[UIFont fontWithName:@"Helvetica-Bold" size:30.0f];
[test addAttribute:NSFontAttributeName value:font range:NSMakeRange(0, test.length)];
[test drawAtPoint:r.origin];
}
}
UIGraphicsEndImageContext();
}
}