renderInContext 创建未立即释放的内存
在使用“ObjectAlloc”在仪器中进行调试时,我注意到为 renderInContext 调用分配了 7megs 内存,但它从未被释放。当我注释掉 renderInContext 调用时,这种情况不会发生,并且将来的 renderInContext 调用不会继续增加内存分配。
UIGraphicsBeginImageContext(contentHolder.bounds.size);
[contentHolder.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
有没有办法强制释放这段内存?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了如何释放 renderInContext 内存。只需在主线程上运行调用 renderInContext 的方法即可自动释放分配的内存。
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.