Zheng
Zheng

Reputation:

sizeWithFont memory leak in iphone

I have this code:

[[data objectForKey:[keys objectAtIndex:0]]
                     sizeWithFont:[UIFont systemFontOfSize:12]  
                     constrainedToSize:CGSizeMake(276.0, 1000.0)  
                     lineBreakMode:UILineBreakModeTailTruncation];

data is a NSDictionary.

It is said this code has 16 bytes leak, but I cant find it.

Help

Upvotes: 0

Views: 590

Answers (2)

mahboudz
mahboudz

Reputation: 39376

Do you leak only one 16byte block for the entire life of your app? Or are you leaking 16 bytes every time through a loop?

If it is 16 bytes only, I am not sure if I'd worry too much about it. I'm saying that given that some of the caching I have seen done by the OS tends to look like leaking.

Upvotes: 0

zaph
zaph

Reputation: 112857

What type does the NSDictionary return?

[[data objectForKey:[keys objectAtIndex:0]]

Break the statement up to better figure out where the leak may be:

NSString *s = [[data objectForKey:[keys objectAtIndex:0]];
CGSize size = [s sizeWithFont:[UIFont systemFontOfSize:12]
            constrainedToSize:CGSizeMake(276.0, 000.0)
                lineBreakMode:UILineBreakModeTailTruncation];

Upvotes: 2

Related Questions