NSData * buffer = [fileHandle readDataOfLength:chunkSize];
while ([buffer length] > 0)
{
[streamBIG writeData:buffer];
offset += [buffer length];
[fileHandle seekToFileOffset:offset];
buffer = [fileHandle readDataOfLength:chunkSize];
}
我使用这些特定的进程来压缩超过1个25 - 30 MB的文件,但是这些增加了内存,即实时字节不断增加,直到所有文件都没有写入,因为我的应用程序崩溃了
答案 0 :(得分:2)
尝试使用自动发布池
NSData * buffer = [fileHandle readDataOfLength:chunkSize];
while ([buffer length] > 0)
{
@autoreleasepool
{
[streamBIG writeData:buffer];
offset += [buffer length];
[fileHandle seekToFileOffset:offset];
buffer = [fileHandle readDataOfLength:chunkSize];
}
}
它会起作用......