Memory is not release after conversion by using Aspose words

I am trying to convert all the below required files into pdf format and output will be stored in outputStream that I have destored at Finally stage when the request has been finished…Please find the below code :

if (inputStream == null)
{
    throw new ArgumentNullException(nameof(inputStream));
}

fileExt = FormatFileExtension(fileExt);
outputStream = new MemoryStream();

if (pdfExtensions.Contains(fileExt, StringComparer.InvariantCultureIgnoreCase))
{
    var pdfStream = new MemoryStream();
    inputStream.CopyTo(pdfStream);
    pdfStream.Position = 0;
    return pdfStream;
}

switch (fileExt.ToUpper())
{
    case "DOC":
    case "DOCX":
    case "TXT":
        var wordDoc = new Aspose.Words.Document(inputStream);
        wordDoc.Save(outputStream, Aspose.Words.SaveFormat.Pdf);
        break;
    case "PNG":
    case "BMP":
    case "JPG":
    case "JPEG":
        var pdf = new Aspose.Pdf.Document();
        var image = new Image() { ImageStream = inputStream };
        pdf.Pages.Add().Paragraphs.Add(image);
        pdf.Save(outputStream);
        break;
    default:
        throw new NotSupportedException("Unsupported file format");
}

outputStream.Position = 0;
return outputStream;


public void DestroyMemoryStream()
{
    if (outputStream != null)
    {
        outputStream.Dispose();
        outputStream = null; // Clear reference for garbage collection
    }
}

But still it not release the memory after the coversion.
Currently Uses below package:
Aspose.PDF.Drawing: 24.8.0
Aspose.Words: 24.8.0

@cdayalal Doe the problem occur with some particular document on your side? If so, could you please attach it here for testing? Also, please make sure the stream where the document is saved and stream from where the document is loaded are not used anymore and try calling GC.Collect method to make sure the garbage is collected.

It happens with all the document that i am trying to convert. Also tried with GC.Collect but it seems not working. Is there any way to dispose Document object ?

var wordDoc = new Aspose.Words.Document(inputStream);
wordDoc.Save(outputStream, Aspose.Words.SaveFormat.Pdf);
GC.Collect();
GC.WaitForPendingFinalizers();

@cdayalal Document object does not keep any unmanaged resources in memory. So there is no need to dispose it. Unfortunately, I cannot reproduce the problem on my side. If possible, please create a simple console application that will demonstrate the problem.
Also, you should note that Aspose.Words inits some static resources, that are kept in memory. So there might be small memory footprint after using Aspose.Words. But this allocated memory does not grow when you convert more documents.