<?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: Dapple 1.2 and NSString Leaks</title>
	<atom:link href="http://www.streamingcolour.com/blog/2009/05/27/dapple-12-and-nsstring-leaks/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.streamingcolour.com/blog/2009/05/27/dapple-12-and-nsstring-leaks/</link>
	<description>The trials and joys of indie games development</description>
	<lastBuildDate>Sat, 28 Jan 2012 19:32:30 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Doug</title>
		<link>http://www.streamingcolour.com/blog/2009/05/27/dapple-12-and-nsstring-leaks/comment-page-1/#comment-3956</link>
		<dc:creator>Doug</dc:creator>
		<pubDate>Sat, 30 May 2009 16:12:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.streamingcolour.com/blog/?p=628#comment-3956</guid>
		<description>@Owen: Thanks!  I will check it out.

As far as JSON. I&#039;ve been using it A LOT at work lately and I have to say I love it.  Especially in my case where I submit a javascript array to the backend and if rejected, I can easy recreated the array on the client-side and allow correction.</description>
		<content:encoded><![CDATA[<p>@Owen: Thanks!  I will check it out.</p>
<p>As far as JSON. I&#8217;ve been using it A LOT at work lately and I have to say I love it.  Especially in my case where I submit a javascript array to the backend and if rejected, I can easy recreated the array on the client-side and allow correction.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: OG</title>
		<link>http://www.streamingcolour.com/blog/2009/05/27/dapple-12-and-nsstring-leaks/comment-page-1/#comment-3894</link>
		<dc:creator>OG</dc:creator>
		<pubDate>Fri, 29 May 2009 02:25:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.streamingcolour.com/blog/?p=628#comment-3894</guid>
		<description>@Dominik: I was sure it was a leak because Leaks was telling me so. :)

I wasn&#039;t aware of NSScanner, but that&#039;s definitely something I&#039;ll look into for the next update. Right now I do a lot of error checking on the data coming in from the server. I hope it&#039;s enough...

As for JSON, I don&#039;t know what it is, so that&#039;s why I didn&#039;t consider it. ;)

@Doug - I don&#039;t see myself having a huge load on the servers, but even so, the free quotas that Google App Engine provides are pretty impressive. There are full details here:

http://code.google.com/appengine/docs/quotas.html

Needless to say, I don&#039;t think I&#039;ll be exceeding 10,000,000 datastore API calls per day anytime soon. ;)

As for robustness, it&#039;s built on top of their server cloud, so your datastores are stored across multiple servers (if I understand it correctly). Which means, even if one fails, another server should be able to handle the request. The other nice thing about it is that if someone should happen to hack into the system, it&#039;s not the same server as my website. :)

O.</description>
		<content:encoded><![CDATA[<p>@Dominik: I was sure it was a leak because Leaks was telling me so. <img src='http://www.streamingcolour.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I wasn&#8217;t aware of NSScanner, but that&#8217;s definitely something I&#8217;ll look into for the next update. Right now I do a lot of error checking on the data coming in from the server. I hope it&#8217;s enough&#8230;</p>
<p>As for JSON, I don&#8217;t know what it is, so that&#8217;s why I didn&#8217;t consider it. <img src='http://www.streamingcolour.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>@Doug &#8211; I don&#8217;t see myself having a huge load on the servers, but even so, the free quotas that Google App Engine provides are pretty impressive. There are full details here:</p>
<p><a href="http://code.google.com/appengine/docs/quotas.html" rel="nofollow">http://code.google.com/appengine/docs/quotas.html</a></p>
<p>Needless to say, I don&#8217;t think I&#8217;ll be exceeding 10,000,000 datastore API calls per day anytime soon. <img src='http://www.streamingcolour.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>As for robustness, it&#8217;s built on top of their server cloud, so your datastores are stored across multiple servers (if I understand it correctly). Which means, even if one fails, another server should be able to handle the request. The other nice thing about it is that if someone should happen to hack into the system, it&#8217;s not the same server as my website. <img src='http://www.streamingcolour.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>O.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug</title>
		<link>http://www.streamingcolour.com/blog/2009/05/27/dapple-12-and-nsstring-leaks/comment-page-1/#comment-3893</link>
		<dc:creator>Doug</dc:creator>
		<pubDate>Fri, 29 May 2009 02:13:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.streamingcolour.com/blog/?p=628#comment-3893</guid>
		<description>Owen, care to elaborate a little more on Google App Engine? Is it robust enough to handle the traffic your app might generate?  Does Google have a cap on the number of transactions you can hit them with?  I&#039;ve been thinking of setting up a global space as well, but have been concerned about the backend servers and having to purchase server space.

doug</description>
		<content:encoded><![CDATA[<p>Owen, care to elaborate a little more on Google App Engine? Is it robust enough to handle the traffic your app might generate?  Does Google have a cap on the number of transactions you can hit them with?  I&#8217;ve been thinking of setting up a global space as well, but have been concerned about the backend servers and having to purchase server space.</p>
<p>doug</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dominik</title>
		<link>http://www.streamingcolour.com/blog/2009/05/27/dapple-12-and-nsstring-leaks/comment-page-1/#comment-3841</link>
		<dc:creator>Dominik</dc:creator>
		<pubDate>Wed, 27 May 2009 22:07:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.streamingcolour.com/blog/?p=628#comment-3841</guid>
		<description>I have to second what Iain says: Immutable Strings won&#039;t be copied, but just retained due to efficiency.

In addition it&#039;s not quite clear to me why you think you need that loop for clearing your cache. The only thing could be that you might have some cyclic references in your cache. Otherwise I&#039;d be really surprised that this won&#039;t work. What makes you sure that this is indeed a leak?
The second version leaks the username and that should be the reason why you have to loop through the array and release it manually.

In addition &#039;componentsSeparatedByString&#039; is a cool convenient method, but you can get into a whole lot of trouble, when the data you receive is not what you expect (NSScanner does a good job in reliably parsing strings). (Just think about somebody is spamming your online high score list with some data, which probably could easily crash your app).

Why didn&#039;t you consider using JSON, this would have taken the burden away from you having to parse the data yourself?

Btw. it&#039;s more efficient to do
for(NSMutableDictionary* record in mCachedGlobalHighScores) { ...</description>
		<content:encoded><![CDATA[<p>I have to second what Iain says: Immutable Strings won&#8217;t be copied, but just retained due to efficiency.</p>
<p>In addition it&#8217;s not quite clear to me why you think you need that loop for clearing your cache. The only thing could be that you might have some cyclic references in your cache. Otherwise I&#8217;d be really surprised that this won&#8217;t work. What makes you sure that this is indeed a leak?<br />
The second version leaks the username and that should be the reason why you have to loop through the array and release it manually.</p>
<p>In addition &#8216;componentsSeparatedByString&#8217; is a cool convenient method, but you can get into a whole lot of trouble, when the data you receive is not what you expect (NSScanner does a good job in reliably parsing strings). (Just think about somebody is spamming your online high score list with some data, which probably could easily crash your app).</p>
<p>Why didn&#8217;t you consider using JSON, this would have taken the burden away from you having to parse the data yourself?</p>
<p>Btw. it&#8217;s more efficient to do<br />
for(NSMutableDictionary* record in mCachedGlobalHighScores) { &#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bunnyhero</title>
		<link>http://www.streamingcolour.com/blog/2009/05/27/dapple-12-and-nsstring-leaks/comment-page-1/#comment-3838</link>
		<dc:creator>bunnyhero</dc:creator>
		<pubDate>Wed, 27 May 2009 21:14:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.streamingcolour.com/blog/?p=628#comment-3838</guid>
		<description>how odd... to my eye, that looks like it shouldn&#039;t leak! and from what i know of objective-C (which could certainly be wrong), it shouldn&#039;t matter that the string is stored as an id rather than NSString*.

also, i&#039;ve read in several places (mostly forum posts, some from apple employees, iirc) that the retainCount method can&#039;t necessarily be relied upon to tell you what&#039;s really going on leakwise, because of implementation details. it might return what looks like a &#039;wrong&#039; value, but not actually be leaking there.

curiouser and curiouser... it seems like it&#039;d be worth filing as a bug with apple if you can reproduce it in a small test app.</description>
		<content:encoded><![CDATA[<p>how odd&#8230; to my eye, that looks like it shouldn&#8217;t leak! and from what i know of objective-C (which could certainly be wrong), it shouldn&#8217;t matter that the string is stored as an id rather than NSString*.</p>
<p>also, i&#8217;ve read in several places (mostly forum posts, some from apple employees, iirc) that the retainCount method can&#8217;t necessarily be relied upon to tell you what&#8217;s really going on leakwise, because of implementation details. it might return what looks like a &#8216;wrong&#8217; value, but not actually be leaking there.</p>
<p>curiouser and curiouser&#8230; it seems like it&#8217;d be worth filing as a bug with apple if you can reproduce it in a small test app.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: OG</title>
		<link>http://www.streamingcolour.com/blog/2009/05/27/dapple-12-and-nsstring-leaks/comment-page-1/#comment-3834</link>
		<dc:creator>OG</dc:creator>
		<pubDate>Wed, 27 May 2009 20:38:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.streamingcolour.com/blog/?p=628#comment-3834</guid>
		<description>@Iain - That certainly looks simpler. I did realise that adding a string to the array resulted in a retain, which gets released when you remove the object from the array.

However, it was when I tried to let everything work through the autorelease stuff that I ran into problems with sometimes things not being released (and hence a leak), which is why I put the explicit alloc in there. It&#039;s entirely possible that I&#039;m doing something else dumb with my memory stuff.

This is why I don&#039;t like smart pointers. If I have to manage my own memory, at least it forces me to understand what&#039;s going on all the time. ;)</description>
		<content:encoded><![CDATA[<p>@Iain &#8211; That certainly looks simpler. I did realise that adding a string to the array resulted in a retain, which gets released when you remove the object from the array.</p>
<p>However, it was when I tried to let everything work through the autorelease stuff that I ran into problems with sometimes things not being released (and hence a leak), which is why I put the explicit alloc in there. It&#8217;s entirely possible that I&#8217;m doing something else dumb with my memory stuff.</p>
<p>This is why I don&#8217;t like smart pointers. If I have to manage my own memory, at least it forces me to understand what&#8217;s going on all the time. <img src='http://www.streamingcolour.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Iain Delaney</title>
		<link>http://www.streamingcolour.com/blog/2009/05/27/dapple-12-and-nsstring-leaks/comment-page-1/#comment-3833</link>
		<dc:creator>Iain Delaney</dc:creator>
		<pubDate>Wed, 27 May 2009 20:28:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.streamingcolour.com/blog/?p=628#comment-3833</guid>
		<description>I think what you&#039;re missing here is that adding an object to an array or dictionary sends that object a retain message. You shouldn&#039;t need the string alloc-init at all.

This should work:
NSArray* recordData = [[records objectAtIndex:i]
                       componentsSeparatedByString:@&quot;,&quot;];

[dict setObject:[recordData objectAtIndex:0] forKey:@&quot;name&quot;];

No allocs, no retains, no releases. 
It&#039;s also important to note that the runtime saves memory whenever possible. So copying a string, if the string is immutable, just results in a new pointer and an incremented retain count. Check the values of your pointers to see if they are pointing at the same object.</description>
		<content:encoded><![CDATA[<p>I think what you&#8217;re missing here is that adding an object to an array or dictionary sends that object a retain message. You shouldn&#8217;t need the string alloc-init at all.</p>
<p>This should work:<br />
NSArray* recordData = [[records objectAtIndex:i]<br />
                       componentsSeparatedByString:@&#8221;,&#8221;];</p>
<p>[dict setObject:[recordData objectAtIndex:0] forKey:@&#8221;name&#8221;];</p>
<p>No allocs, no retains, no releases.<br />
It&#8217;s also important to note that the runtime saves memory whenever possible. So copying a string, if the string is immutable, just results in a new pointer and an incremented retain count. Check the values of your pointers to see if they are pointing at the same object.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

