Vibhooti
Vibhooti

Reputation: 1203

large number of large files creating leak while creating zip file

NSData * buffer = [fileHandle readDataOfLength:chunkSize];
                while ([buffer length] > 0)
                {
                    [streamBIG writeData:buffer];
                    offset += [buffer length];

                    [fileHandle seekToFileOffset:offset];
                    buffer = [fileHandle readDataOfLength:chunkSize];
                }

I use these particular process to zip more then 1 file of 25 - 30 MB but these increases memory i.e. live bytes continuously increase till all files are not written, because of which my app crashes

Upvotes: 2

Views: 270

Answers (1)

Ganapathy
Ganapathy

Reputation: 4614

Try like this with Auto release pool

               NSData * buffer = [fileHandle readDataOfLength:chunkSize];
                while ([buffer length] > 0)
                {
                    @autoreleasepool
                    {
                    [streamBIG writeData:buffer];
                    offset += [buffer length];

                    [fileHandle seekToFileOffset:offset];
                    buffer = [fileHandle readDataOfLength:chunkSize];
                    }
                }

it will work...

Upvotes: 2

Related Questions