lloydsargent / BlackRaccoon

IOS FTP Client Code
102 stars 37 forks source link

Memory warning #60

Closed ApesTalk closed 8 years ago

ApesTalk commented 8 years ago

When i upload a big image(about 3MB),the app received memory waring and crashed.

lloydsargent commented 8 years ago

1) Are you uploading FROM the iOS device or downloading TO the iOS device? 2) Have you set breakpoints to see when and where the memory warning happens? 3) By “crash” to you mean “SIGABRT” or something else?

ApesTalk commented 8 years ago

I uploaded image from the iOS device to ftp sever. For example, In the directory below A. Because A contains a lot of image, when i upload image ,the memory cost increased to 600MB+, so the APP crashed because memory warning. in contrast, when A contains a small amount of image, it did not cost much memory.

Have any solutions?

lloydsargent commented 8 years ago

You can never load a very large image all into memory and successfully transfer. I have reiterated this multiple times. You must transfer it from a file piece by piece. Many people, including myself, have discovered this.

What you want to do is read a file, a small section at a time, and transfer it using:

- (NSData *) requestDataToSend: (BRRequestUpload *) request

You will return a SMALL PART (a few kilobytes) of the large file. That is the point of it. You return sections of the file bit by bit. This is the only way you can send a large file to an FTP server.