<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
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/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
> <channel><title>以太之内 生存之上 &#187; 内存管理</title> <atom:link href="http://ixhan.com/tag/%e5%86%85%e5%ad%98%e7%ae%a1%e7%90%86/feed/" rel="self" type="application/rss+xml" /><link>http://ixhan.com</link> <description>Live in your world, get owned in mine</description> <lastBuildDate>Wed, 08 Feb 2012 10:38:57 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>栽大了之Objc过度释放对象</title><link>http://ixhan.com/2009/11/shit-on-objc-object-manager/</link> <comments>http://ixhan.com/2009/11/shit-on-objc-object-manager/#comments</comments> <pubDate>Thu, 26 Nov 2009 09:37:28 +0000</pubDate> <dc:creator>xhan</dc:creator> <category><![CDATA[Coding]]></category> <category><![CDATA[iOS]]></category> <category><![CDATA[apple]]></category> <category><![CDATA[决定]]></category> <category><![CDATA[内存管理]]></category> <category><![CDATA[c]]></category> <category><![CDATA[objective-c]]></category> <guid
isPermaLink="false">http://ixhan.com/?p=196</guid> <description><![CDATA[<a
href="http://ixhan.com/2009/11/shit-on-objc-object-manager/" title="栽大了之Objc过度释放对象"></a>事情是这样的,4个月前我写了份实现类似下拉框选择操作的界面. 一个月前,发现了这个View 在dealloc 会crash掉. 多次调试无果,上 devForum.apple.com 询问也无人问津. 今天决定再次调试下,还是没找到哪里出问题. 最后决定求助 cocoachina 上的现场观众 最后开始一行一行的注释代码做终极调试. 离谱的事情发现了,只要我创建一个名为 mainText 的 UILabel ,在dealloc 中程序就会crash ,改成其他名字无事.难道是apple的bug? 新写了个view测试了,还是没问题. 接着接着就发现了在dealloc方法中: [mainText release] ,mainText = nil; // NSLog(@"release %@",bgView); [bgView release]; // NSLog(@"release %@",originView); [originView release]; // NSLog(@"release %@",labelArray); [labelArray &#8230;<p
class="read-more"><a
href="http://ixhan.com/2009/11/shit-on-objc-object-manager/">Read more &#187;</a></p>]]></description> <content:encoded><![CDATA[<a
href="http://ixhan.com/2009/11/shit-on-objc-object-manager/" title="栽大了之Objc过度释放对象"></a><p>事情是这样的,4个月前我写了份实现类似下拉框选择操作的界面.<br
/> 一个月前,发现了这个View 在dealloc 会crash掉.<br
/> 多次调试无果,上 devForum.apple.com 询问也无人问津.<br
/> 今天决定再次调试下,还是没找到哪里出问题.<br
/> 最后决定求助 cocoachina 上的现场观众<br
/> 最后开始一行一行的注释代码做终极调试.</p><p>离谱的事情发现了,只要我创建一个名为 mainText 的 UILabel ,在dealloc 中程序就会crash ,改成其他名字无事.难道是apple的bug? 新写了个view测试了,还是没问题.</p><p>接着接着就发现了在dealloc方法中:<br
/> <code> [mainText release] ,mainText = nil;<br
/> //	NSLog(@"release %@",bgView);<br
/> [bgView release];<br
/> //	NSLog(@"release %@",originView);<br
/> [originView release];<br
/> //	NSLog(@"release %@",labelArray);<br
/> [labelArray release];<br
/> //	NSLog(@"release %@",mainText);<br
/> [mainText release];<br
/> </code><br
/> 该死的,不知道当时那根神经错了,居然释放了两次,当然出错咯.问题也解决了.</p><p>所以在确认释放对象的情况下一定要写成:<br
/> [instance release],instance = nil ;</p><p>个人经验是,对于objective-c的内存管理都是得经过磨练才出来的,前期多犯错误是好事情.<br
/> 当然我认识一个朋友 ,他不释放任何对象,因为反正关闭iPhone后系统会处理的.这种觉悟不是大部分程序员有的,大家还是稳步前进咯.</p><h3  class="related_post_title">Related Posts</h3><ul
class="related_post"><li><a
href="http://ixhan.com/2009/12/minesweeperever/" title="永远的扫雷英雄(开源) 登场">永远的扫雷英雄(开源) 登场</a></li><li><a
href="http://ixhan.com/2010/04/apple-such-a-bitch/" title="Apple 发疯了">Apple 发疯了</a></li><li><a
href="http://ixhan.com/2009/12/dec-review/" title="12月串烧-年轻人就要飘逸">12月串烧-年轻人就要飘逸</a></li><li><a
href="http://ixhan.com/2009/11/things-ive-done-in-past-5-months/" title="Things I&#8217;ve done int past 5 months">Things I&#8217;ve done int past 5 months</a></li></ul>]]></content:encoded> <wfw:commentRss>http://ixhan.com/2009/11/shit-on-objc-object-manager/feed/</wfw:commentRss> <slash:comments>145</slash:comments> </item> </channel> </rss>
