I. Processing PS/EPS documents.
With a simple application, iterating 1000 times over the same input file and attempt transforming it into a image, it was noticed a continuous growth of memory allocated to the process. Here is the Main
namespace Application
{
class Program
{
static void Main(string[] args)
{
EPSRender.RegisterAsposeLicenses();
for (int i = 0; i < 1000; i++)
{
EPSRender.Render(@"c:\Temp\source.eps", @"c:\Temp\destination.jpg");
Console.WriteLine($"Done {i}...");
}
Console.WriteLine($"Done!!!");
Console.ReadKey();
}
And the EPSRender code (inspired from Page Description Language Converters | .NET):
public static class EPSRender
{
public static void RegisterAsposeLicenses()
{
var license = new License();
license.SetLicense("Aspose.Total.NET.lic");
Console.WriteLine("Aspose.Page license set successfully.");
}
private static readonly ImageSaveOptions bitmapOptions = new ImageSaveOptions()
{
JpegQualityLevel = 100,
SupressErrors = true
};
public static void Render(string inputFileName, string outputFileName)
{
FileStream psStream = new FileStream(inputFileName, FileMode.Open, FileAccess.Read);
PsDocument document = new PsDocument(psStream);
ImageSaveOptions options = new ImageSaveOptions(true);
ImageDevice device = new ImageDevice();
try
{
document.Save(device, options);
}
finally
{
psStream.Close();
}
device.Dispose();
psStream.Dispose();
GC.SuppressFinalize(document);
}
As it can be seen within the code, the Dispose and garbage collection was even forced after each iteration, hoping that this is going to clear things up. However, at the end of the 1000 iterations, the memory was significantly big with no sign of releasing. This is how the snapshot looks like:
The NuGet package used for this application was Aspose.Page v.20.7.0
Question: The PsDocument class does not have the IDispose interface. Is there a different way of releasing the resources allocated by it? Or this is in fact a memory leak?
II. Upgrading to the latest Aspose.Page 20.8.0.
Using the same sample application .Net Core console application, but this time with the latest Aspose.Page library available into the NuGet repository, the compilation ends up into a bunch of errors:
After looking into the folder where the libraries are stored, the size of the dll was zero.
If the application is having the reference to version 20.7.0 restored, everything comes back to normal.
Question: Is the support for .NET Core dropped for this library or is just a deployment issue?