Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.
Hello, I want to have a download method for my iPhone, I got a download method, but when the file is bigger than 60 mb, the app crashes. Anyone has any ideas?.
Hello, I want to have a download method for my iPhone, I got a download method, but when the file is bigger than 60 mb, the app crashes. Anyone has any ideas?.
Use an NSFileHandle or NSStream to write the data directly to a file as it's downloaded, rather than building it up in memory. There was a thread with sample code on this very subject a week or so ago. I suggest searching on "NSFileHandle" to find it.
Regards,
Duncan C WareTo
Animated GIF created with Face Dancer, available for free in the app store.
Use an NSFileHandle or NSStream to write the data directly to a file as it's downloaded, rather than building it up in memory. There was a thread with sample code on this very subject a week or so ago. I suggest searching on "NSFileHandle" to find it.
Post your current download code that crashes when the files are too large. Also, show what you tried.
This is the code I've used, I guess that the problem would be in the saveData method or in the connection:didReceiveData, but I can't figure out what it can be.
Creates a new copy of every piece of incoming data, and then promptly leaks it. As a result, you need twice as much free RAM as the incoming data, and leak a whole copy of the data.
There is no reason to duplicate the incoming data. Rewrite that line as:
[receivedData appendData: data]];
Depending on how big the files you're downloading, that might solve your problem.
Regards,
Duncan C WareTo
Animated GIF created with Face Dancer, available for free in the app store.
Replies
Duncan C
WareTo
Animated GIF created with Face Dancer, available for free in the app store.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeDuncan C
WareTo
Animated GIF created with Face Dancer, available for free in the app store.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeI'll see if I can find the time to rework your code to save the data bit-by-bit to a file using an NSFileHandle.
In the meantime, though, the code you posted has a HUGE leak. This line:
Creates a new copy of every piece of incoming data, and then promptly leaks it. As a result, you need twice as much free RAM as the incoming data, and leak a whole copy of the data.
There is no reason to duplicate the incoming data. Rewrite that line as:
Depending on how big the files you're downloading, that might solve your problem.
Duncan C
WareTo
Animated GIF created with Face Dancer, available for free in the app store.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome