ios plist檔案和載入到記憶體時佔用空間大小

來源:互聯網
上載者:User

標籤:style   blog   io   ar   color   os   sp   for   on   

plist檔案以文本形式儲存,一個字元佔用一個位元組,外加plist檔案的頭部,佔用空間就是所有的字元數。

載入到記憶體所佔空間與檔案大小一致。

比如下方一個字串是300個字元。10000個Object Storage Service到檔案中,檔案大小為3.2MB。載入到記憶體所佔空間也是3.2MB

- (void)viewDidLoad {    [super viewDidLoad];    // Do any additional setup after loading the view, typically from a nib.    NSMutableArray *array = [[NSMutableArray alloc] init];        for (int i=0; i<10000; i++) {        [array addObject:@"adsjadslkjfksdajfklasjdkfkalsdklfadsjadslkjfksdajfklasjdkfkalsdklfadsjadslkjfksdajfklasjdkfkalsdklfadsjadslkjfksdajfklasjdkfkalsdklfadsjadslkjfksdajfklasjdkfkalsdklfadsjadslkjfksdajfklasjdkfkalsdklfadsjadslkjfksdajfklasjdkfkalsdklfadsjadslkjfksdajfklasjdkfkalsdklfadsjadslkjfksdajfklasjdkfkalsdklfa300"];    }    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);    NSString *documentsDirectory = [paths objectAtIndex:0];    NSString *fileName = @"1.plist";    NSString *filePath = [documentsDirectory stringByAppendingPathComponent:fileName];    NSLog(@"path is : %@",filePath);    [array writeToFile:filePath atomically:YES];        NSArray *arr2 = [NSArray arrayWithContentsOfFile:filePath];    self.arr2 = arr2;    NSLog(@"");    }

 

ios plist檔案和載入到記憶體時佔用空間大小

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.