qileilove

          blog已經(jīng)轉(zhuǎn)移至github,大家請(qǐng)?jiān)L問(wèn) http://qaseven.github.io/

          IOS-內(nèi)存檢測(cè)以及優(yōu)化

            PS:開(kāi)始寫(xiě)這個(gè)系列的筆記:主要是對(duì)過(guò)去自己比較模糊的一些概念進(jìn)行測(cè)試,明確結(jié)果,提高自己
            IOS 應(yīng)用如果占用系統(tǒng)的內(nèi)容過(guò)大(8GB),就會(huì)造成應(yīng)用直接被系統(tǒng)以崩潰的形式關(guān)閉,一次控制應(yīng)用占用的內(nèi)存大小是非常重要的事情。
            現(xiàn)在我們來(lái)看看,一個(gè)空的應(yīng)用占據(jù)的內(nèi)容的大?。?/div>
            測(cè)試環(huán)境:xCode 5.0/IOS 5
            啟動(dòng)一個(gè)空應(yīng)用,占用的內(nèi)存為 2.6MB,占據(jù)應(yīng)用崩潰的閥值為 0.03%
            1:關(guān)于導(dǎo)航條的 Push和popup的測(cè)試結(jié)果
            [self.navigationController pushViewController:m_navanimated:YES];
            [self.navigationController popViewControllerAnimated:YES];
            對(duì)于
            pushViewController ,會(huì)將對(duì)應(yīng)的ViewController對(duì)象的引用計(jì)數(shù)器+1
            popViewControllerAnimated   會(huì)將對(duì)應(yīng)的ViewController對(duì)象的引用計(jì)數(shù)器-1
            但是有一點(diǎn)需要明確的是,對(duì)于函數(shù)
            -(void)dealloc
            {
            //Objects release here
            [super deallco];
            }
            只有在該引用計(jì)數(shù)器的值==0的時(shí)候才會(huì)調(diào)用,這個(gè)是必須牢記的。
            在執(zhí)行函數(shù)[self.navigationController popViewControllerAnimated:YES];的時(shí)候,如果彈出的ViewController對(duì)應(yīng)的引用計(jì)數(shù)器為0,那么也會(huì)執(zhí)行dealloc 函數(shù)。
            所以再使用
            [self.navigationController pushViewController:m_navanimated:YES];
            [self.navigationController popViewControllerAnimated:YES];
            棧函數(shù)對(duì)的時(shí)候,為了釋放內(nèi)存,我們可以這么使用
            Nav_1 *m_nav = [[[Nav_1  alloc] initWithNibName:nil bundle:nil] autorelease];
            [self.navigationController  pushViewController:m_nav  animated:YES];
            這樣就最大限度的節(jié)省了寶貴的內(nèi)存空間

          posted on 2014-08-04 09:56 順其自然EVO 閱讀(426) 評(píng)論(1)  編輯  收藏 所屬分類: 測(cè)試學(xué)習(xí)專欄

          評(píng)論

          # re: IOS-內(nèi)存檢測(cè)以及優(yōu)化[未登錄](méi) 2014-10-15 16:45 Andy

          最后Nav_1 *m_nav = [[[Nav_1 alloc] initWithNibName:nil bundle:nil] autorelease];
            [self.navigationController pushViewController:m_nav animated:YES];
          這樣就節(jié)省了內(nèi)容,是什么原因,沒(méi)看懂  回復(fù)  更多評(píng)論   

          <2014年8月>
          272829303112
          3456789
          10111213141516
          17181920212223
          24252627282930
          31123456

          導(dǎo)航

          統(tǒng)計(jì)

          • 隨筆 - 3936
          • 文章 - 404
          • 評(píng)論 - 179
          • 引用 - 0

          常用鏈接

          留言簿(55)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          •  

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 唐山市| 桑日县| 思南县| 景泰县| 泰和县| 曲阳县| 枣强县| 灌阳县| 合江县| 崇义县| 无极县| 大石桥市| 博客| 锦州市| 庆云县| 承德市| 育儿| 澎湖县| 曲松县| 江川县| 辉县市| 青岛市| 桦甸市| 龙井市| 东乌珠穆沁旗| 徐汇区| 苏州市| 长治县| 广安市| 乾安县| 安仁县| 秦皇岛市| 博爱县| 论坛| 武宁县| 宝鸡市| 秀山| 乌拉特后旗| 新乡县| 惠东县| 都江堰市|