Iphone memory leak

 label = (UILabel *)[cell.contentView viewWithTag:1];
            label.text =labelString; 
            size = [label.text sizeWithFont:[UIFont fontWithName:@"ArialMT" size:14] constrainedToSize:CGSizeMake(320,9999)  lineBreakMode:UILineBreakModeWordWrap];
            label.frame = CGRectMake(5, 5, 295, (size.height+25));

UIFont leaves a leak of 256 bytes.

And some other leaks are also present in my application related to the web kit and the Foundation library.

NSString *path = [[NSBundle mainBundle] pathForResource:@"Prayers" ofType:@"html"];
    NSFileHandle *readHandle = [NSFileHandle fileHandleForReadingAtPath:path];

    NSString *htmlString = [[NSString alloc] initWithData:
                            [readHandle readDataToEndOfFile] encoding:NSUTF8StringEncoding];

These lines leave leaks of UIKit WebKit and DataDetectorsCore.

Please suggest any solution to this problem. The total skipped memory is about 3 KB, maybe I leave this in the application or not.

+4
source share
3 answers

I doubt you have a leak in instances of UITableViewCell. You have made some custom UITableViewCells, perhaps you need to check these UITableViewCells.

+1
source

UIFont, , . , UIFont , - UIFont fontWithName.

0

I noticed that it UIFontmight skip memory when called from outside the main thread. Put a statement in front of your code. This will allow you to catch the error.

assert([NSThread isMainThread]);
0
source

Source: https://habr.com/ru/post/1775783/


All Articles