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

Free Support Forum - aspose.com

Aspose.Email for .NET 17.6 / System.OutOfMemoryException

Dear ASPOSE,

I have a service which verify each minute my mailbox (internal mailbox for our company) if there is a non flaged email since three day. If there is, it fetchs and it puts a flag on the new mail.

I’ve started this service on a good windows SERVER 2012 R2 with 2G ram, at 6:18pm. But this morning, I saw that there is this OutOfMemory error which is repeated (of cours each minute) since 6am :

> Une exception de type 'System.OutOfMemoryException' a été levée.

>    à #=qTynLNR7lusKCwHmg69FHL67FoAnHtPDovmsLKfE$QxDQYwHrOs9PcCTVJo2UFX62.#=qY0I$BEG6kpGkqwLqtRdppCQrJtSuCVFEvNmgZh7NnlU=(String #=qaCm62e53yHOL$OHaQMX9cQ==, Int32 #=qabsbelbwz8pOHWHme1CVfQ==)
>    à #=qCwhieg2Kx_FtZMdR32v19dHCPpFoJlrlmDhwM0P8RnukOfEE8ZoIT9heSz$PLgiG.#=qkj59OF14v8Te34V2SPRKvw==(Int32 #=qarDyfZt0bZalTZSKf2MqAA==)
>    à #=qCwhieg2Kx_FtZMdR32v19dHCPpFoJlrlmDhwM0P8RnukOfEE8ZoIT9heSz$PLgiG.#=q2rRJZkANBPReD1$xVSXb8Q==()
>    à Aspose.Email.Clients.Imap.ImapClient.ListMessages(MailQuery query, Int32 maxNumberOfMessages)
>    à Aspose.Email.Clients.Imap.ImapClient.ListMessages(MailQuery query)
>    à XXX.FetchUnreadSupportEmail(String host, Int32 port, String username, String password, String libraryRootPath, Int32 maxFileLength)
>    à InfosServeurs.Scheduler.ServiceScheduler.ProcessTasks(Settings settings, DateTime currentDate)
>    à InfosServeurs.Scheduler.ServiceScheduler.Treat()


> Une exception de type 'System.OutOfMemoryException' a été levée.

>    à #=qTynLNR7lusKCwHmg69FHL67FoAnHtPDovmsLKfE$QxDQYwHrOs9PcCTVJo2UFX62.#=qdkZtDsX4$R2fB9jdWxTY1ismRMmFIRgZ_E44ctvso4s=(String #=qaCm62e53yHOL$OHaQMX9cQ==, Int32 #=qabsbelbwz8pOHWHme1CVfQ==)
>    à #=qTynLNR7lusKCwHmg69FHL67FoAnHtPDovmsLKfE$QxDQYwHrOs9PcCTVJo2UFX62.#=qcW7kqa8dG3oXpjCQ$hdNW5S_b5TU11kOUH6wB448vRc=.#=q9LAtpy1OBeE77ZMfuIPBkv_Hx4NrcKlBOe16uIavK8KFHhxYsB3FUQeKmpCERlE$(Object #=qzffE0XQ0hIe_2760Pi4BAw==)


> Une exception de type 'System.OutOfMemoryException' a été levée.

>    à System.Threading.Thread.StartInternal(IPrincipal principal, StackCrawlMark& stackMark)
>    à System.Threading.Thread.Start(StackCrawlMark& stackMark)
>    à System.Threading.Thread.Start()

I put here my checking code which is written by your help (FetchUnreadSupportEmail function):

                 using (TransactionScope scope = new TransactionScope())
                {        
                ImapClient client = new ImapClient(host, port, username, password);

                ImapQueryBuilder builder = new ImapQueryBuilder();

                //Put interval (Get only messages for today)
                builder.InternalDate.BeforeOrEqual(DateTime.Now);
                builder.InternalDate.Since(DateTime.Today.AddDays(-3));

                //Read messages with no flag
                builder.HasNoFlags(ImapMessageFlags.Flagged);

                MailQuery query = builder.GetQuery();

                ImapMessageInfoCollection coll = client.ListMessages(query);

                Console.WriteLine(coll.Count + " new emails for today and not flagged! at " + DateTime.Now.ToString());...

Thanks for you help,

Best regards,

Alireza

@alireza.tadbir,

We are sorry for the inconvenience caused to you.

We have tried sample email messages at our end but were not able to reproduce any such problem at our end. Could you please share more info about the sample email message for which the application raises exception? If possible, please share the sample messages with us for further investigation at our end.

1 Like

Thanks for your response.

My problem is not based on a special message.

Maybe, at the moment that it raises the ‘System.OutOfMemoryException’, there is no message for treating! And maybe not, but it’s not based on the mails (because as I’ve tested, at the 6am there were no new mail!). It takes this error automatically after some hours of checking regularly (each minute) our mailbox by using this function: client.ListMessages.

Is there any way to empty the memory for each iteration? (iteration on checking mail)

In additional, here is the graph of memory which shows us the memory is not saturate !!! (It’s for today)
1.png (13.2 KB)

If you want to test it, you have to create a service in c# and put a timer (for example with 1 minute), and foreach iteration, you check the mailbox (as I check in the first message, here in this page).

And you will see, in some hours, it will be System.OutOfMemoryException exception without saturating the RAM !

@alireza.tadbir,

Could you please share your sample C# Service here for further investigation at our end? Please also try disposing the IMAP client by calling client.Dispose() method and let us know your feedback.

1 Like

By using Dispose, it seems works correctly. (After 48h, I have no error !)

Thanks :slight_smile:

You are welcome.