我在加载存到数据库中的pdf文件(大约14M)的二进制数据时,通过
[data appendData:[self.archiveData subdataWithRange:NSMakeRange(self.offset, len)]];加载数据
len是int类型offset是NSInteger类型。
self.offset += len;
但是当self.offset增加到差不多7M左右的时候就会报错导致程序崩溃。错误如下:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** NSAllocateMemoryPages(14082573) failed' *** First throw call stack:
( 0 CoreFoundation 0x06345946 exceptionPreprocess + 182
1 libobjc.A.dylib 0x05fcea97 objcexceptionthrow + 44
2 CoreFoundation 0x0634586d +[NSException raise:format:] + 141
3 Foundation 0x04f800ac NSAllocateMemoryPages + 106
4 Foundation 0x04e8e643 _NSDataCreateVMDispatchData + 34
5 Foundation 0x04e8c83a -[_NSPlaceholderData initWithBytes:length:copy:deallocator:] + 252
6 Foundation 0x04e8c72d -[NSData(NSData) initWithBytes:length:copy:freeWhenDone:bytesAreVM:] + 92
7 Foundation 0x04ee9363 -[NSData(NSData) copyWithZone:] + 144
8 CoreFoundation 0x062c4ce9 -[NSCFData copyWithZone:] + 105
9 Foundation 0x04f33531 -[NSSubrangeData initWithData:range:] + 484
10 Foundation 0x04ef3727 -[NSData(NSData) subdataWithRange:] + 657
11 ESPTablet 0x00edf137 -[CWHessianUnarchiver(Private) readDataWithTag:] + 189
12 ESPTablet 0x00edf1b3 -[CWHessianUnarchiver(Private) readDataWithTag:] + 313
13 ESPTablet 0x00edf1b3 -[CWHessianUnarchiver(Private) readDataWithTag:] + 313
14 ESPTablet 0x00edf1b3 -[CWHessianUnarchiver(Private) readDataWithTag:] + 313
15 ESPTablet 0x00edf1b3 -[CWHessianUnarchiver(Private) readDataWithTag:] + 313
16 ESPTablet 0x00edf1b3 -[CWHessianUnarchiver(Private) readDataWithTag:] + 313
17 ESPTablet 0x00edf1b3 -[CWHessianUnarchiver(Private) readDataWithTag:] + 313
。。。。错误还有很多没有全贴出来
这个错误好像是分配内存失败了
请教各位大神,知道这是什么原因吗?