<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: How to background load and cache UIImageViews images</title>
	<atom:link href="http://www.roathe.com/2009/12/how-to-background-load-and-cache-uiimageviews-images/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.roathe.com/2009/12/how-to-background-load-and-cache-uiimageviews-images/</link>
	<description>Where the web comes to die...</description>
	<lastBuildDate>Thu, 24 Jun 2010 19:52:44 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Lane Roathe</title>
		<link>http://www.roathe.com/2009/12/how-to-background-load-and-cache-uiimageviews-images/comment-page-1/#comment-152</link>
		<dc:creator>Lane Roathe</dc:creator>
		<pubDate>Thu, 24 Jun 2010 19:52:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.roathe.com/?p=179#comment-152</guid>
		<description>Andy and Warren were both correct in pointing out that the code I uploaded has a bug where the caching dictionary is autoreleased and needs to be contained. I adapted the code from a library where the dictionary reference is a method in an object and synthesized with a retain property.

To fix the line


		_cache = [NSMutableDictionary dictionaryWithCapacity:MAX_CACHED_IMAGES];

to


		_cache = [[NSMutableDictionary dictionaryWithCapacity:MAX_CACHED_IMAGES] retain];

Warren is correct when he points out that doing so will leak this object, because the cache dictionary is never released. However, since it&#039;s a static it will only leak one dictionary and that will be released when your app exits.

I&#039;ll revisit this code and see if I can&#039;t come up with a way to solve this issue without loosing the simplicity of the existing solution (ie, no classes to create, etc.).

Thanks for the feedback guys, apologies it took so long to reply (new job and all :) ).

-lane</description>
		<content:encoded><![CDATA[<p>Andy and Warren were both correct in pointing out that the code I uploaded has a bug where the caching dictionary is autoreleased and needs to be contained. I adapted the code from a library where the dictionary reference is a method in an object and synthesized with a retain property.</p>
<p>To fix the line</p>
<p>		_cache = [NSMutableDictionary dictionaryWithCapacity:MAX_CACHED_IMAGES];</p>
<p>to</p>
<p>		_cache = [[NSMutableDictionary dictionaryWithCapacity:MAX_CACHED_IMAGES] retain];</p>
<p>Warren is correct when he points out that doing so will leak this object, because the cache dictionary is never released. However, since it&#8217;s a static it will only leak one dictionary and that will be released when your app exits.</p>
<p>I&#8217;ll revisit this code and see if I can&#8217;t come up with a way to solve this issue without loosing the simplicity of the existing solution (ie, no classes to create, etc.).</p>
<p>Thanks for the feedback guys, apologies it took so long to reply (new job and all <img src='http://www.roathe.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ).</p>
<p>-lane</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Warren M</title>
		<link>http://www.roathe.com/2009/12/how-to-background-load-and-cache-uiimageviews-images/comment-page-1/#comment-142</link>
		<dc:creator>Warren M</dc:creator>
		<pubDate>Mon, 17 May 2010 21:05:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.roathe.com/?p=179#comment-142</guid>
		<description>This is an elegant solution to the problem, easily adapted to existing code. Your approach definitely was helpful for my project.

My only concern is (and this may be something I introduced in adapting your example), it seems like the dictionary you get from dictionaryWithCapacity: is autoreleased, and the code doesn&#039;t retain it. I saw a situation where my app crashed because the cache was dealloc&#039;d while in use because of this. Adding a call to retain prevents this, but also introduces a small leak as long as the program is running.

You mention your own objections to using a static variable in an accessor, but I think this is still the most pragmatic approach since using +initialize with a static global will still introduce an object that persists until the application is exiting.</description>
		<content:encoded><![CDATA[<p>This is an elegant solution to the problem, easily adapted to existing code. Your approach definitely was helpful for my project.</p>
<p>My only concern is (and this may be something I introduced in adapting your example), it seems like the dictionary you get from dictionaryWithCapacity: is autoreleased, and the code doesn&#8217;t retain it. I saw a situation where my app crashed because the cache was dealloc&#8217;d while in use because of this. Adding a call to retain prevents this, but also introduces a small leak as long as the program is running.</p>
<p>You mention your own objections to using a static variable in an accessor, but I think this is still the most pragmatic approach since using +initialize with a static global will still introduce an object that persists until the application is exiting.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy Jacobs</title>
		<link>http://www.roathe.com/2009/12/how-to-background-load-and-cache-uiimageviews-images/comment-page-1/#comment-131</link>
		<dc:creator>Andy Jacobs</dc:creator>
		<pubDate>Mon, 03 May 2010 15:16:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.roathe.com/?p=179#comment-131</guid>
		<description>very useful!!! except i stil get this error messages

2010-05-03 17:11:32.695 base1[9629:6417] *** _NSAutoreleaseNoPool(): Object 0x1566a90 of class NSCFDictionary autoreleased with no pool in place - just leaking
Stack: (0x305a2e6f 0x30504682 0x4d543 0x4d5be 0x3050a79d 0x3050a338 0x909c4a19 0x909c489e)
2010-05-03 17:11:32.695 base1[9629:5a13] *** _NSAutoreleaseNoPool(): Object 0x1566dd0 of class NSCFDictionary autoreleased with no pool in place - just leaking
Stack: (0x305a2e6f 0x30504682 0x4d543 0x4d5be 0x3050a79d 0x3050a338 0x909c4a19 0x909c489e)
2010-05-03 17:11:32.695 base1[9629:5813] *** _NSAutoreleaseNoPool(): Object 0x1567130 of class NSCFDictionary autoreleased with no pool in place - just leaking
Stack: (0x305a2e6f 0x30504682 0x4d543 0x4d5be 0x3050a79d 0x3050a338 0x909c4a19 0x909c489e)
2010-05-03 17:11:32.698 base1[9629:4917] *** _NSAutoreleaseNoPool(): Object 0x1567460 of class NSCFDictionary autoreleased with no pool in place - just leaking
Stack: (0x305a2e6f 0x30504682 0x4d543 0x4d5be 0x3050a79d 0x3050a338 0x909c4a19 0x909c489e)</description>
		<content:encoded><![CDATA[<p>very useful!!! except i stil get this error messages</p>
<p>2010-05-03 17:11:32.695 base1[9629:6417] *** _NSAutoreleaseNoPool(): Object 0x1566a90 of class NSCFDictionary autoreleased with no pool in place &#8211; just leaking<br />
Stack: (0x305a2e6f 0&#215;30504682 0x4d543 0x4d5be 0x3050a79d 0x3050a338 0x909c4a19 0x909c489e)<br />
2010-05-03 17:11:32.695 base1[9629:5a13] *** _NSAutoreleaseNoPool(): Object 0x1566dd0 of class NSCFDictionary autoreleased with no pool in place &#8211; just leaking<br />
Stack: (0x305a2e6f 0&#215;30504682 0x4d543 0x4d5be 0x3050a79d 0x3050a338 0x909c4a19 0x909c489e)<br />
2010-05-03 17:11:32.695 base1[9629:5813] *** _NSAutoreleaseNoPool(): Object 0&#215;1567130 of class NSCFDictionary autoreleased with no pool in place &#8211; just leaking<br />
Stack: (0x305a2e6f 0&#215;30504682 0x4d543 0x4d5be 0x3050a79d 0x3050a338 0x909c4a19 0x909c489e)<br />
2010-05-03 17:11:32.698 base1[9629:4917] *** _NSAutoreleaseNoPool(): Object 0&#215;1567460 of class NSCFDictionary autoreleased with no pool in place &#8211; just leaking<br />
Stack: (0x305a2e6f 0&#215;30504682 0x4d543 0x4d5be 0x3050a79d 0x3050a338 0x909c4a19 0x909c489e)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
