Rank: Newbie
Groups: Registered
Joined: 11/6/2016(UTC) Posts: 2
EASendMailObj.dll Version 7.3.0.1 hi, one of my users is getting the error "Out of memory" (-2147352567) at the function call "SendMail()". Some infos about the computer running the software: OS: Windows 10 (Build 14393) Version: 10.0 ID: 2 PhysRAM: 1.562,03 MB Free / 3.063,11 MB Total MemLoad: 49% RAM used: 274,46 MB Pagefile: 4.431,36 MB Free / 6.135,11 MB Total VirtMem: 1.626,99 MB Free / 2.047,88 MB Total can anyone help to sort out this problem?
Rank: Administration
Groups: Administrators
Joined: 11/11/2010(UTC) Posts: 1,153
Thanks: 9 times Was thanked: 55 time(s) in 55 post(s)
Hi, could you tell me how large the email is? How many attachment were added and the attachment size?
Rank: Newbie
Groups: Registered
Joined: 11/6/2016(UTC) Posts: 2
Originally Posted by: ivan Hi, could you tell me how large the email is? How many attachment were added and the attachment size?
Sorry, i dont have this information yet.
I tried to reproduce this problem at my computer and attached a large file with 154mb.
The app started sending the email and i checked with the tool TCPview the transfer to the email server. After some time i got the error message "Error with sending data;socket error - DATA stream".
The memory usage of my app jumped from 9.072K to 663.324K using a attachment with 154mb after the data sending is started. Using a attachment with 404MB the memory usage jumped to 1.715.836K! The memory usage dropped down to 13.000K after the error message occurred. Why does a 404MB file need 1.7GB RAM?
It looks like that you first read the complete content of the attachment into the memory and after that you start sending the data. That is ok for small emails but with large attachments it would be a much smarter programming style to read the attachment on thy fly chunk by chunk when sending the data to the email server, or?
Lets say you have a 32bit app with a maximum possible RAM usage of 2GB and your app already used 1.8GB of the RAM and now you want to send an email with a large attachment...out of memory ;-)
Error message from your DLL when sending an email with an 754mb attachment:
You should handle this "out of memory" error inside your DLL and return a normal error message because this crashes my app too and i cant catch the error message :(
Edited by user Thursday, November 10, 2016 6:28:34 PM(UTC)
| Reason: added a screenshot
Rank: Administration
Groups: Administrators
Joined: 11/11/2010(UTC) Posts: 1,153
Thanks: 9 times Was thanked: 55 time(s) in 55 post(s)
OK, thanks for your valuable comments, I will improve it in a couple of days.
Rank: Administration
Groups: Administrators
Joined: 11/11/2010(UTC) Posts: 1,153
Thanks: 9 times Was thanked: 55 time(s) in 55 post(s)
Hi, after I double-checked this problem.
Yes, it takes 1-4 times memory of the attachment when it is generating the email mime stream.
Let me explain:
If the attachment size is 400MB, after you called AddAttachment method, the binary data of the attachment will be stored in memory (400MB). Before sending data to SMTP server, the attachment should be encoded in base64 at first, it will take about 550MB. Then it combines body/header/attachment MIME part to a mime stream, the entire stream size is about 600MB. The problem is: before encoded base64 (550MB) is copied to the mime stream, it couldn't be destroyed. So the maximum memory usage is about 1.6 or 1.7GB. After the mime stream is generated, the base64 (550MB) will be destroyed. After the email is sent, the mime stream (600MB) will be destroyed. After you call ClearAttachments method, the binary data of attachment (400MB) will be destroyed. The Mail object didn't return a normal error, it throws a com exception, it can be caught like this:
Code:
try
{
}
catch( _com_error &ep )
{
_tprintf( _T("Error: %s"), (const TCHAR*)ep.Description());
}
But i will change the exception to normal error at next version, and you can use GetLastErrDescription to get the error. I also compiled a quick version which doesn't throw exception, just return non-zero with SendMail method and you can get the error by GetLastErrDescription, please check your forum private message, i sent the download URL to you.
PS: Almost none SMTP server will accept so large email (i thought 100MB is common limit), so you may add some limit in your codes.
Forum Jump
EmailArchitect Support
Email Component Development
- EASendMail SMTP Component - .NET Version
- EASendMail SMTP Component - Windows Store Apps
- EASendMail SMTP ActiveX Object
- EAGetMail POP3 & IMAP4 Component - .NET Version
- EAGetMail POP3 & IMAP4 ActiveX Object
Exchange Server and IIS SMTP Plugin
- DomanKeys/DKIM for Exchange Server and IIS SMTP
- Disclaimer and S/MIME for Exchange Server and IIS
EmailArchitect Email Server
- EmailArchitect Email Server (General)
- EmailArchitect Email Server Development
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.