AsposePDF - OutOfMemoryException

Hello,
I have a service that encrypts pdf files and adds to a zip archive. When managing large files (I’ve tested with a 555MB file) it generates a OutOfMemoryException. The service is running on a Windows Server 2016 with 16GB of RAM and when it throws the exception the process is using about 1.2GB of RAM.
I’m using AsposePDF libraries for .NET version 19.5.0.
The exception is thrown exactly after the invocation of Save method on Document object.
Here is a sample of my code:

Int32 bufferSize = Int32.Parse(ConfigurationManager.AppSettings["bufferSize"]);
byte[] buffer = new byte[bufferSize];

System.IO.DirectoryInfo directorySelected;

System.IO.FileStream destinationStream = System.IO.File.Create(System.IO.Path.Combine(outDir, compressedFilename));
using (ZipOutputStream stream = new ZipOutputStream(destinationStream))
{
	foreach (System.IO.FileInfo f in directorySelected.GetFiles())
	{
		ZipEntry zipEntry = new ZipEntry(f.Name);
		stream.PutNextEntry(zipEntry);
		
		using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
		{
			f.OpenRead().CopyTo(ms);
			using (Aspose.Pdf.Document docpdf = new Aspose.Pdf.Document(ms))
			{
				DocumentPrivilege documentPrivilege = DocumentPrivilege.ForbidAll;
				documentPrivilege.AllowPrint = true;
				PdfFileSecurity fileSecurity = new PdfFileSecurity(docpdf);
				fileSecurity.SetPrivilege(null, "XXXXXXXXX", documentPrivilege);
				System.IO.MemoryStream o = new System.IO.MemoryStream();
				
				docpdf.Save(o, Aspose.Pdf.SaveFormat.Pdf);
				o.Position = 0;
				
				int sourceBytes;
				do
				{
					sourceBytes = o.Read(buffer, 0, buffer.Length);
					stream.Write(buffer, 0, sourceBytes);
				}
				while (sourceBytes > 0);
			}
		}
	}
}

@Taleasrl

Would you kindly try to use the latest version of the API i.e. 21.9 as it is always recommended to use latest version due to maximum fixes and improvements it has. In case issue still persists at your end, please share a sample PDF document with which we can test the scenario in our environment and address it accordingly. You can please upload your document to Google Drive or Dropbox and share the link with us.