TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

How a bug in ported garbage-collected code trashed our iOS app

66 pointsby asarazanalmost 12 years ago

9 comments

asarazanalmost 12 years ago
I should note that, while we saw something like 0.4% increased crash rate, we actually don&#x27;t have a number to compare it against for memory crashes.<p>This is because if memory usage gets too high, the OS will send a kill signal to the process, which can be neither detected nor caught.<p>This means that in our original decision to use this fix, all we had was anecdotal evidence of untraceable crashes. Luckily we had dedicated QA that was keeping pretty solid track of them all, and they piled up.<p>In our case I think it was worth it.
评论 #5882058 未加载
评论 #5882525 未加载
jkubicekalmost 12 years ago
Our app uses this method to cache images and we were seeing <i>huge</i> memory leaks due to this bug. Like the example showed, the bug manifested itself in a retain count being incremented on property access. Our solution was something like this:<p><pre><code> if ([self.data retainCount] != [self.data retainCount]) { [[[self.data release] release] release]; } </code></pre> Written from memory, so excuse any mistakes. First (and only) time I&#x27;ve ever seen a legitimate use for `retainCount`. @bbum would be proud (or perhaps horrified).
评论 #5883054 未加载
评论 #5883222 未加载
mikeashalmost 12 years ago
The link to garbage collection is a bit odd. The garbage collector does not, of course, exist on iOS, and this bug has nothing to do with garbage collection. It&#x27;s just a memory leak due to bad manual memory management. It <i>just so happens</i> that this leak is in code that&#x27;s written to also work when garbage collection is on, but the leak isn&#x27;t due to, or even related to, garbage collection.<p>This may be nitpicking, but it made it hard for me to pay attention to the real meat of the thing.
评论 #5882008 未加载
Scorponokalmost 12 years ago
Aren&#x27;t you living dangerously by still using garbage collection on iOS at this point? Apple keep making dire statements about how everyone needs to stop using it, so I&#x27;d be worried that iOS8 will just remove it entirely, meaning apps that use GC just wouldn&#x27;t work at all on that OS...
评论 #5881928 未加载
评论 #5881915 未加载
shaggyfrogalmost 12 years ago
What I love about these stories from the trenches isn&#x27;t just seeing how the mystery gets solved (although that part is great), but seeing the evolution of the investigation -- which might be the more valuable of the two things when it comes to improving your own bug tracking skills.
gte910halmost 12 years ago
The title confused me: It was redefinition of a GC related function that lead to the bug. It has nothing to do with the existence of a GC on iOS.
评论 #5882751 未加载
评论 #5883317 未加载
bogardonalmost 12 years ago
What I really want to know is why NSURLCache does not go to disk when it should. And also if it&#x27;s fixed in iOS 7...
评论 #5882740 未加载
notthetupalmost 12 years ago
So tl;dr NSURLCache has a memory leak, be careful when using it.. Or?
gdonellialmost 12 years ago
There is no GC in iOS
评论 #5883226 未加载