Free Support Forum - aspose.com

Memory leak when running Aspose Email 20.10 via thread

Hi guys,
I’m using Aspose Email v20.10 to extract these messages in PST file.
{Sample code}:

class Program
{
    public static int ProcessFile(String inputFile)
    {
        PersonalStorage pst = null;
        try
        {
            using(pst = PersonalStorage.FromFile(inputFile, true))
            {
                MessageInfoCollection messageInfoCollection = pst.RootFolder.GetContents();
                messageInfoCollection.Clear();
                messageInfoCollection = null;
            }
        }
        catch(Exception ex)
        {
        }
        finally
        {
            GC.WaitForPendingFinalizers();
            System.GC.Collect();
            if(pst != null)
            {
                pst.Dispose();
                pst = null;
            }
        }
        return 0;
    }

    static void Main(string[] args)
    {
        String inputFile = @"sample_files.pst";

        // set license
        License pstLicense = new License();
        pstLicense.SetLicense("Aspose.Total.lic");

        // press key to watching init resource
        System.Console.WriteLine("press any key from keyboard to memory resource usage");
        System.Console.Read();

        for(int i = 0; i < 10000; i++)
        {
            // Creating thread to extract file
            Thread t = new Thread(() =>
            {
                ProcessFile(inputFile);
            });
            t.Start();
            t.Join();
        }

        System.Console.WriteLine("Finish process, waiting to exit...................");
        System.Console.Read();
        while(true)
        {
        }
    }
}

Step to reproduce:
Step 1: Press any key from the keyboard, watching memory resource as below:
init_resource.png (23.1 KB)

The memory usage is 24,460 KB

Step 2: After the test finish, the console outputs the log “Finish process, waiting to exit…”, the memory usage as below:
current_resource.png (22.3 KB)
The memory usage is 110,036 KB

I run this code on Windows 10 64bit, Aspose Email 20.10

Please investigate this problem. Thanks. sample_files.zip (1.1 MB)

@dunghnguyen

I have created a ticket with ID EMAILNET-39982 in our issue tracking system to further investigate the issue on our end. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

Hi @mudassir.fayyaz
Thank you for your support. It will be great if this issue could be fixed soon. It is urging to me.

@dunghnguyen

I regret to share that at present the issue is unresolved. We are hopeful to get this fixed in upcoming Aspose.Email for .NET 20.12.

The issues you have found earlier (filed as EMAILNET-39982) have been fixed in this update.