Im testing your Aspose.Words for .NET product.
Consider this lines of code:
public string ToPdf(string filename, string fileAsBase64)
{
string filepath = FileRepository.BaseFilepath + filename + ".pdf";
var bytes = Convert.FromBase64String(fileAsBase64);
using (var stream = new MemoryStream(bytes))
{
try
{
var document = new Document(stream);
var saveOptions = SaveOptions.CreateSaveOptions(SaveFormat.Pdf);
saveOptions.MemoryOptimization = true;
document.Save(filepath, saveOptions);
}
catch (Exception e)
{
// logger here
throw e;
}
}
return filepath;
}
My testing app looks like this:
[Benchmark]
public List<string> Synchronous()
{
var result = new List<string>();
foreach (var file in data.Files)
{
result.Add(ToPdf(file.Filename, file.ContentBase64));
}
return result;
}
in data.Files property exist 10 files with 16 pages.
im storing documents in list of FileDto with property Content - in this property each document exist converted to Base64 as string.
The results presents:
| Method | Mean | Error | StdDev | Gen 0 | Gen 1 | Gen 2 | Allocated |
|-------------- |--------:|---------:|---------:|------------:|-----------:|----------:|----------:|
| Synchrous | 3.485 s | 0.1763 s | 0.4945 s | 117000.0000 | 26000.0000 | 6000.0000 | 636.66 MB |
As you can see from 100 runs amount of allocated memory is 640mb avarage. Is it normal memory usage of Aspose.Words for converting documents in loop?