iPhone - UIImage 泄漏、ObjectAlloc 构建
好吧,我很难追踪这个内存泄漏。运行此脚本时,我没有看到任何内存泄漏,但我的 objectalloc 正在攀升。 Instruments 指向 CGBitmapContextCreateImage >创建位图数据提供者> malloc,这占用了我的 objectalloc 的 60%。
使用 NSTimer 多次调用此代码。
返回后如何清除 reUIImage?
...或者如何才能使 UIImage imageWithCGImage 不构建我的 ObjectAlloc?
//I shorten the code because no one responded to another post
//Think my ObjectAlloc is building up on that retUIImage that I am returning
//**How do I clear that reUIImage after the return?**
-(UIImage) functionname {
//blah blah blah code
//blah blah more code
UIImage *retUIImage = [UIImage imageWithCGImage:cgImage];
CGImageRelease(cgImage);
return retUIImage;
}
Alright I am having a world of difficulty tracking down this memory leak. When running this script I do not see any memory leaking, but my objectalloc is climbing. Instruments points to CGBitmapContextCreateImage > create_bitmap_data_provider > malloc, this takes up 60% of my objectalloc.
This code is called several times with a NSTimer.
How do I clear that reUIImage after I return it?
...or How can I make it so that UIImage imageWithCGImage does not build my ObjectAlloc?
//I shorten the code because no one responded to another post
//Think my ObjectAlloc is building up on that retUIImage that I am returning
//**How do I clear that reUIImage after the return?**
-(UIImage) functionname {
//blah blah blah code
//blah blah more code
UIImage *retUIImage = [UIImage imageWithCGImage:cgImage];
CGImageRelease(cgImage);
return retUIImage;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您使用的此方法实例化一个 UIImage 并将其设置为自动释放。如果你想清理它们,你需要定期清空池。
请注意,它们可以嵌套:
常见的做法是将它们放置在 for 循环和其他生成许多自动释放对象的方法周围。
this method you use instantiates a UIImage and sets it as autorelease. If you want to cleanup these, you will need to empty the pool periodically
Note that these can be nested:
Common practice is to place these around for loops and other methods that make many autoreleased objects.