iphone - Images not freed on memory warning when using [UIImage imageNamed] -


in app, i've used line

[uiimage imagenamed:imagename]  

whenever loading image. understand it, function caches images later use - great, because of images used more once.

but - when simulate memory warning, memory used these images doesn't seem freed according - , since of memory in fact used cached images, pretty important unneeded images released memory!

-

is expected behavior, or images remain in memory due fact it's simulated memory warning? or, if want release these images, have write own category uiimage caches images releases uneeded ones when memory in short supply (or better, has done this/shared code it)??

what have done create own caching mechanism utilizing -initwithconentsoffile doesnt cache, , nsmutabledictionary storing, every image allocated stored in dictionary image name key. if memory warning reached can release , nil dictionary releasing memory allocated images.

this gives complete control on image caching. -imagenamed: uses own caching mechanism have no control on when , allocated memory released.

you should try method well.

edit: heres uiimage class extension (https://gist.github.com/2880240), overriding -imagenamed: custom cache, upon receiving memory warning can use [uiimage freecache]. included, ability set autorelease on images upon storing them in cache, i.e: [uiimage setshouldautorelease:true]. false default.

give try, hope helps!


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -