Reputation: 215
I have a slider used to change the font size of the text in a UITextView. Analyzer and Leaks report no memory leak. However, the memory grows each time I change the font size by moving the slider. Eventually the app gets an out of memory warning. The code is:
mainText.font = [UIFont systemFontOfSize:mainSlider.value];
If I replace that code with mainText.font = [UIFont systemFontOfSize:40.0];
, memory stays the same no matter how many times I move the slider. I searched this and many other sites looking for info on a possible UIFont bug. No success. I see people using the same code I am using and not mentioning increasing memory. Please help.
Upvotes: 2
Views: 954
Reputation: 6286
There is probably a font cache in place to avoid regenerating the same fonts over and over again (a bit like [UIImage imageNamed:@""])
It is not explicitly stated in the docs but reading
You do not create UIFont objects using the alloc and init methods. Instead, you use class methods of UIFont to look up and retrieve the desired font object. These methods check for an existing font object with the specified characteristics and return it if it exists. Otherwise, they create a new font object based on the desired font characteristics.
could make one believe there is a cache
Also, what are you calling an "out of memory warning"? I presume it's just a "memory warning level=1", and not an application crash because of out-of-memory?
Upvotes: 1