Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

renderInContext creating memory that is not promptly released

While debugging in instruments using 'ObjectAlloc' I'm noticing 7megs of memory being allocated for the renderInContext call, but it never is released. When I comment out the renderInContext call this doesn't happen, and future renderInContext calls does not continue to increase the memory allotment.

UIGraphicsBeginImageContext(contentHolder.bounds.size);
[contentHolder.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

Is there a way to force this memory to be released?

like image 994
Steven Baughman Avatar asked Feb 02 '26 09:02

Steven Baughman


1 Answers

I found out how to release the renderInContext memory. Simply run the method calling renderInContext on Main Thread and that will release the allocated memory automatically.

like image 103
Elitecoder Avatar answered Feb 04 '26 22:02

Elitecoder



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!