Search The ForumSearch   RegisterRegister  LoginLogin

MailBee.NET Objects

 AfterLogic Forum : MailBee.NET Objects
Subject Topic: Memory Leak using MsgConvert.EmlToMsg? Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
Oliver
Newbie
Newbie


Joined: 17 September 2014
Location: Austria
Online Status: Offline
Posts: 5
Posted: 17 September 2014 at 3:29am | IP Logged Quote Oliver

Hey there,

we are downloading around 1000 emails from an imap account. The problem is we see a HEAVY increase in memory usage when using the EmltoMsg function.

E.g. we are downloading the mailmessage one by one and for each message we do this ->

Code:

MsgConvert conv = new MsgConvert();
using (MemoryStream eml = new MemoryStream())
{
  using (FileStream fs = new FileStream(sMessageID + ".msg", FileMode.Create))
  {
    msg.SaveMessage(eml);
    eml.Position = 0;
    conv.EmlToMsg(eml, fs);
    fs.Close();
    eml.Close();
  }
}


As you can see I make sure to close all the streams... but if emails are over 10MB you can see the memory jumps up shortly by 100-300MB during conversion... after around 500 calls to eml to msg we then get a outofmemory exception in the emltomsg function.

If we try to use conv.EmlToMsg(string, string) - the memory is raising fast too but not as fast and we also haven't encountered a outofmemory exception yet. But shouldn't the memory stream version (of emltomsg) be more efficient - instead of always saving to disk and using the conv.EmlToMsg(string, string)function?

It appears to me that something is not cleaning up when converting eml to msg, at least if done via streams?

Can you please check that, thanks in advance,
Oliver
Back to Top View Oliver's Profile Search for other posts by Oliver
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6104
Posted: 17 September 2014 at 3:32am | IP Logged Quote Igor

I'll ask the developers to look into this, but first, can you please confirm the issue persists with the latest build of the DLL? You can get one at:

http://www.afterlogic.com/updates/mailbee_net_2.zip (for .NET Framework 2.0 or above)
http://www.afterlogic.com/updates/mailbee_net_4.zip (for .NET Framework 4.0 or above)

--
Regards,
Igor, AfterLogic Support
Back to Top View Igor's Profile Search for other posts by Igor
 
Oliver
Newbie
Newbie


Joined: 17 September 2014
Location: Austria
Online Status: Offline
Posts: 5
Posted: 17 September 2014 at 3:56am | IP Logged Quote Oliver

Hello and thanks for the quick reply. I have just tested the latest versions from your post. Yes it has the same problem.

When downloading a large email and using the emltomsg(stream,stream) function like above I can see a big memory spike moving somtimes by even more than 300MB up (in my test now it spiked shortly from 100MB in task manager to 450 MB and then back to 180MB when executing the emltomsg line). When processing many emails it is more an more increasing until I get a out of memory exception. I don't have this problem though If I use the (string, string) version of the function - even though the memory is also increasing, but not as rapidly.

Thanks for your help,
Oliver
Back to Top View Oliver's Profile Search for other posts by Oliver
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 20 September 2014 at 3:55am | IP Logged Quote Alex

The developers are checking this now. We'll come back to you next week on this.

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 
Oliver
Newbie
Newbie


Joined: 17 September 2014
Location: Austria
Online Status: Offline
Posts: 5
Posted: 22 September 2014 at 12:35am | IP Logged Quote Oliver

Thanks.
Back to Top View Oliver's Profile Search for other posts by Oliver
 
Oliver
Newbie
Newbie


Joined: 17 September 2014
Location: Austria
Online Status: Offline
Posts: 5
Posted: 29 September 2014 at 2:12am | IP Logged Quote Oliver

Any news?
Back to Top View Oliver's Profile Search for other posts by Oliver
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6104
Posted: 29 September 2014 at 2:17am | IP Logged Quote Igor

Hello,

I've just heard from the developers on this, they suggest to run garbage collection after each conversion, or after several of those, using the following line:

Code:
GC.Collect();


Please let us know if this works for you. Thank you!

--
Regards,
Igor, AfterLogic Support
Back to Top View Igor's Profile Search for other posts by Igor
 
Oliver
Newbie
Newbie


Joined: 17 September 2014
Location: Austria
Online Status: Offline
Posts: 5
Posted: 01 October 2014 at 1:47am | IP Logged Quote Oliver

Well I tried this already but it doesn't prevent the program from giving OutofMemory Exception. If I use the same function:

conv.EmlToMsg(string, string) instead of doing it through the memorystream conv.EmlToMsg(stream, stream), then I don't get this outofmemory.

But shouldn't the memorystream option be better than always saving the file to disk just so I can use the EmlToMsg function on the files directly.

So I really wonder why the memorystream function is less memory efficient?

Kind regards,
Oliver
Back to Top View Oliver's Profile Search for other posts by Oliver
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6104
Posted: 13 October 2014 at 4:28am | IP Logged Quote Igor

Hello,

I've just heard from the developers, they've provided a test case and we'd like to ask you run it. Please open a ticket in our HelpDesk to proceed if you're interested.

--
Regards,
Igor, AfterLogic Support
Back to Top View Igor's Profile Search for other posts by Igor
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide