We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

ImapClient out of memory issues

Hi,


I’m using Aspose.Email to connect to IMAP compliant servers to download thousands of emails for processing with other Aspose products.

I am currently experiencing memory issues, what appears to be a leak of some sort which I have traced back to ImapClient. I’ve been able to reproduced this with the attached sample console app which simply connects the server, gets a list of messages and fetches each of them in a repeating loop. The ImapClient and fetched MailMessage object are both disposed of, however memory usage continually rises until an OutOfMemoryException is thrown.

Note, executing through Visual Studio does not appear to show the same symptoms, will need to compile and run stand-alone.

Thanks
Trent

Hi Trent,


Thank you for writing to Aspose support.

I have tested this scenario with the latest version of Aspose.Email for .NET 4.3.0 and till yet i haven’t observed any Out of Memory exception. The test is still running at my end for the last 10 hours and is under observation. I will update you here about my findings after completing a 24 hours test for this issue.

Hmm, interesting as I get an out of memory within minutes, memory usage steadily increases if viewed through the task manager.


Can I ask which .NET Framework you have targetted and which Aspose.Email.dll build you have referenced?

Thanks
Trent

Hi Trent,


I have tested it using target framework .NET 4.5, Windows 7, 32 bit system, 4 GB RAM, Aspose.Email for .NET 4.3.0 (net 4.0) and Visual Studio 2013. I tested it through command prompt and observed that even after fetching more than 50000 messages (running for more than 10 hours) the memory usage is 51 MB.

Please feel free to write us back if you have any other query in this regard.

Hi Kashif,


Could you please try again with the following modification which will just fetch the first message, again through command prompt. When I download a large number of messages I don’t have an issue.

static void FetchFromImap(String host, int port, String username, String password)
{
using (ImapClient imap = new ImapClient(host, port, username, password))
{
imap.SelectFolder(“INBOX”);

var infos = imap.ListMessages();

foreach (var info in infos)
{
using (var message = imap.FetchMessage(info.UniqueId))
{
Console.WriteLine(String.Format(“Fetched message {0:0000}”, ++count));

// Process the message here…
}

break;
}

imap.Disconnect();
}
}

Thanks
Trent

Hi Trent,


Thank you for writing to Aspose support team.

I have re-tested this issue with my Exchange Inbox using your second code sample above and the test went well without any exception. Could you please share your system details with us and the .NET framework that you are targeting? If possible, I would suggest you to please arrange a test account for us with some sample messages in it that we can use to reproduce this issue at our end. We’ll investigate the issue on the test account and assist you further accordingly.

Hi Kashif,


I am able to reproduce this on a Windows 8.1 64-bit workstation targeting .NET Framework 4.5 and referencing the .NET 4.0 build of Aspose.Email.dll.

Unfortunately, our production mail server is not publicly accessible and is internal to our environment (with appropriate firewall rules allowing mail to come in from an external source) as such I cannot provide you with a test account.

However, all of my testing has been local with a local install of hMailServer which I am able to replicate this issue on with a simple test email containing the word Test in the subject line.

Thanks
Trent

Hi Trent,


I am afraid to share that still I am not able to re-produce it using my test exchange account. Could you please give it a try with some other mail server account using some other machine and let us know your feedback?