0

I have a problem in iOS development.

I pass the NSData and some params to the function.

 // this time memory is about 54 MB
 + (NSData*) doFileData : (NSData*) fileData andFileName:(NSString*) fileName{

   NSMutableData *fileContentData = [NSMutableData dataWithData: fileData];
   // after doing the cast line, the memory is about 99 MB
    .....
 }

When I cast the NSData to the NSMutableData , the memory usage from 54MB upper to the 99 MB.

How can I cast the NSData to the NSMutableData using limit memory function?

thank you very much.

Himanth
  • 2,381
  • 3
  • 28
  • 41
dickfala
  • 3,246
  • 3
  • 31
  • 52

1 Answers1

0

You could try use the method + (id)dataWithContentsOfFile:(NSString *)path options:(NSDataReadingOptions)readOptionsMask error:(NSError **)errorPtr;.For the second paramter,you could use NSDataReadingMappedIfSafe.

iticle
  • 131
  • 1
  • 4
  • If I got the NSData is not from path(maybe the NSData is From a large NSData split out), it can't use the datawithcontensOfFile method.. – dickfala Oct 11 '18 at 14:19