schwa/CoreTextToy — pull request #38 by larsxschneider (2012-02-08 17:29:18+00:00)
Title: Fix memory leaks/peaks

NSScanner is leaking due to objects passed by reference. Commit "caf0e21b" is the important one.

Without the fix, live bytes of the app will surpass 2 GB (Simulator).
With the fix, live bytes will not be above 30MB (Simulator).

To test, try this with Instruments:

```
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

[self.window makeKeyAndVisible];

dispatch_async(dispatch_get_main_queue(), ^{

for (int i= 0; i < 5000; i++)
{

NSString *testStr = @"tata
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. \"Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.\" Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. tata";
CMarkupValueTransformer *theTransformer = [[CMarkupValueTransformer alloc] init];

[theTransformer removeHandlerForTag:@"a"];
[theTransformer removeHandlerForTag:@"mark"];
[theTransformer removeHandlerForTag:@"strike"];
[theTransformer removeHandlerForTag:@"font"];

BTagHandler theTagHandler = ^(CSimpleHTMLTag *inTag) {
return [NSDictionary dictionaryWithObject:[NSNumber numberWithFloat:-10.0] forKey:kMarkupSizeAdjustmentAttributeName];
};

[theTransformer addHandler:theTagHandler forTag:@"paragraphHelper"];

NSError *error = nil;
NSAttributedString *attString = [theTransformer transformedValue:testStr error:&error];

CGSize size = [CCoreTextLabel sizeForString:attString
font:kWKPostCellActivityFont
alignment:UITextAlignmentLeft
lineBreakMode:UILineBreakModeWordWrap
contentInsets:UIEdgeInsetsZero
thatFits:CGSizeMake(300, CGFLOAT_MAX)];

}

});

return YES;
}
```