码迷,mamicode.com
首页 > 移动开发 > 详细

ios plist文件和加载到内存时占用空间大小

时间:2014-12-15 10:19:40      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:style   blog   io   ar   color   os   sp   for   on   

plist文件以文本形式存储,一个字符占用一个字节,外加plist文件的头部,占用空间就是所有的字符数。

加载到内存所占空间与文件大小一致。

比如下方一个字符串是300个字符。10000个对象存储到文件中,文件大小为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文件和加载到内存时占用空间大小

标签:style   blog   io   ar   color   os   sp   for   on   

原文地址:http://www.cnblogs.com/huangzizhu/p/4164204.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!