我这里有内存管理问题吗?
这里的代码一定有问题:
+ (UIImage*)captureView:(UIView *)theView {
UIGraphicsBeginImageContext(theView.frame.size);
[theView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
当我使用它时,Xcode 向我抛出以下错误消息:
malloc:* 对象错误 0x103f000:未释放指针 已分配 *在malloc_error_break中设置断点进行调试
我在那里看不到任何内存管理错误。还有其他人吗?
Something must be wrong with this code right here:
+ (UIImage*)captureView:(UIView *)theView {
UIGraphicsBeginImageContext(theView.frame.size);
[theView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
When I use that, Xcode throws me this error message:
malloc: * error for object
0x103f000: pointer being freed was not
allocated
* set a breakpoint in malloc_error_break to debug
I can't see any memory management errors there. Does anyone else?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我也有同样的警告。但是,在 3.1 或更高版本中不会出现这种情况。
I had the same warning. But, it does not occur in 3.1 or above.
别看。在构建中设置启用 NSZombie 来追踪它。
它可能与从类方法返回自动释放的 UIImage 有关,该方法可能位于临时自动释放池内。该图像可能会因该池的排水而被破坏。要进行测试,请将方法移至实例方法并查看问题是否消失。
Don't see. Set
NSZombie
enabled in the build to track it down.It might be related to returning an autoreleased UIImage from a class method which will probably be inside of a temporary autorelease pool. The image might be being destroyed by the draining of that pool. To test, move the method to an instance method and see if the problem goes away.