zoukankan      html  css  js  c++  java
  • ios plist文件和加载到内存时占用空间大小

    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(@"");
        
    }
  • 相关阅读:
    圆的国度:Can you understand what you see?
    P5732 杨辉三角
    Django中与CSRF相关的内容
    Python中一些可能会问到的面试题
    python协程,线程的其他方法
    python 线程
    python-进程-其他方法(2)
    python 进程的一些其他方法
    python进程--传参,for循环创建,join方法
    python并发编程
  • 原文地址:https://www.cnblogs.com/huangzizhu/p/4164204.html
Copyright © 2011-2022 走看看