I just discovered IKImageView leaks a huge amount of memory (possibly the entire image data) when quickly releasing an instance and then creating a new one and do it again. There are also smaller memory leaks in the implementation reported by the Instruments Leaks tool.
Based on my analysis, I think there is a race condition problem in the IKImageView implementation which is contributing to the big memory leak. I posted a simple reproducible test case at GitHub: https://github.com/ewmailing/MyAppleBugs https://github.com/downloads/ewmailing/MyAppleBugs/IKImageViewTestMemLeak.zip It loads a large image using IKImageView. It loads an image on start up. There is a button called reload. When you hit reload, the IKImageView will be released/dealloc'd and a new IKImageView instance will be created to take its place. If you hit the reload button many times fast and if you watch either Allocations in Instruments (Created & Still Living) or watch the memory utilization in Activity Monitor, the memory keeps going up. Note that Leaks doesn't seem to show the big memory increases as leaks so maybe IKImageView has some kind of retain cycle problem. However, there are small memory leaks showing up. I verified that this is a problem in both 10.7 and 10.8. I didn't test 10.5 and 10.6. (I never noticed the leak until now but it explains some mysterious bugs my users have reported for a long time.) Anyway, I was wondering if anybody has encountered this or knows a workaround. I tried calling setImageWithURL with nil before releasing to see if I could force unload the data before the dealloc, but that didn't seem to help. I discovered if I put a performSelectorWithDelay for some amount of time between the release and the new allocation, the large memory leak doesn't seem to occur. (The small leaks seem to still be a problem though.) This makes me think there is some kind of race condition in the implementation. The performWithDelay workaround may be difficult for me to employ in the real world so I was hoping there might be better ideas. I know I could write my own replacement for IKImageView, but it is more work than I really want to do. (Just filed radar://12106230) Thanks, Eric -- Beginning iPhone Games Development http://playcontrol.net/iphonegamebook/ _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com