Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
micc  
#1 Posted : Sunday, November 6, 2016 10:50:04 PM(UTC)
micc

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?
ivan  
#2 Posted : Monday, November 7, 2016 1:39:45 AM(UTC)
ivan

Rank: Administration

Groups: Administrators
Joined: 11/11/2010(UTC)
Posts: 1,012

Thanks: 9 times
Was thanked: 37 time(s) in 37 post(s)
Hi, could you tell me how large the email is? How many attachment were added and the attachment size?
micc  
#3 Posted : Thursday, November 10, 2016 6:13:10 PM(UTC)
micc

Rank: Newbie

Groups: Registered
Joined: 11/6/2016(UTC)
Posts: 2

Originally Posted by: ivan Go to Quoted Post
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:
out of memory error

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

ivan  
#4 Posted : Friday, November 11, 2016 12:25:18 AM(UTC)
ivan

Rank: Administration

Groups: Administrators
Joined: 11/11/2010(UTC)
Posts: 1,012

Thanks: 9 times
Was thanked: 37 time(s) in 37 post(s)
OK, thanks for your valuable comments, I will improve it in a couple of days.
ivan  
#5 Posted : Tuesday, November 15, 2016 7:22:41 PM(UTC)
ivan

Rank: Administration

Groups: Administrators
Joined: 11/11/2010(UTC)
Posts: 1,012

Thanks: 9 times
Was thanked: 37 time(s) in 37 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.


Users browsing this topic
Forum Jump  
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.

Powered by YAF.NET | YAF.NET © 2003-2019, Yet Another Forum.NET
This page was generated in 0.182 seconds.

EXPLORE TUTORIALS

© All Rights Reserved, AdminSystem Software Limited.