Open xaphod opened 6 years ago
I think memory could be released before disconnecting with mailsmtp_quit().
You could add a MC_SAFE_RELEASE(mMessageData)
under this line:
Let me know if it helps and then please send a pull request over if it's the case.
Thanks for your amazingly quick & useful reply - I owe you 🍺🍺🍺 I'll get a build out with that fix, and if the crash doesn't come back, consider it fixed and send a pull request. Will take some time.
Mailcore2 totally rocks! It is super helpful, I really appreciate it being open-source.
I spent all day today going through this, and I cannot figure it out. What's happening since the latest update of my app: i'm seeing crash-reports from iOS 10.2 where there are 50+ threads all stuck on the same trace as below. It seems like whatever server the user is using is either taking forever to answer the SMTP bye command, or some TCP timeout is happening (it seems like mailcore's default there is 300 seconds, quite long).
all 50+ threads the same as above
The issue is that during the time these threads are waiting, I believe they are holding onto the data in memory, ie
MCOMessageBuilder.data()
, which is large because it contains a JPG attachment (ie. can be 5MB). So since 50+ of these are hanging around, that's 250MB gone -- and my app is being killed / OOM'd.@dinhviethoa can this be the case: that after the
sendOperation
is done, the attachment memory is still retained by the SMTPSession or some other object, until the SMTPDisconnect operation completes? ... I tried to figure it out myself, couldn't... Is it a bug that so many of these run in parallel like this?--> it'd be awesome if the
Data
could be passed in as a file, NOT Data, so no memory is consumed until it is actually neededThings I made sure of with the debugger:
MCOMessageBuilder
and all the other mailcore bits is successfully deallocated as soon asMCOSMTPSession.sendOperation()
completes, ie. it doesn't appear to be my object(s) holding onto the memoryMy code:
Many thanks again for Mailcore2, and any help would be super useful, thanks.