iOS plist files and takes up space when loaded into memory

Source: Internet
Author: User

The plist file is stored as text, one character occupies one byte, and the head of the plist file is occupied, which is the total number of characters.

The amount of space loaded into memory is the same as the file size.

For example, a string below is 300 characters. 10,000 objects are stored in a file with a file size of 3.2MB. 3.2MB of space to load into memory

- (void) viewdidload {[Super viewdidload]; //additional setup after loading the view, typically from a nib.Nsmutablearray *array =[[Nsmutablearray alloc] init];  for(intI=0; i<10000; i++) {[Array addobject:@"ADSJADSLKJFKSDAJFKLASJDKFKALSDKLFADSJADSLKJFKSDAJFKLASJDKFKALSDKLFADSJADSLKJFKSDAJFKLASJDKFKALSDKLFADSJADSLKJFKSDAJFK Lasjdkfkalsdklfadsjadslkjfksdajfklasjdkfkalsdklfadsjadslkjfksdajfklasjdkfkalsdklfadsjadslkjfksdajfklasjdkfkalsdklfadsjads lkjfksdajfklasjdkfkalsdklfadsjadslkjfksdajfklasjdkfkalsdklfa300"]; } 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 files and takes up space when loaded into memory

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.