I've recently ported an ASP.NET web project to ASP.NET Core (net5.0).
In this project static HTML files are converted to PDF files and stored in a database. We are using EvoPDF for this and everything was fine before we switched to net5.0.
Now from time to time we'll get this error:
System.Exception: Could not create image object. Out of memory.
at EvoPdf.HtmlToImageConverter.?(String A_0, String A_1, String A_2, ?& A_3, Hashtable& A_4)
at EvoPdf.HtmlToPdfConverter.?(String A_0, String A_1, String A_2, String A_3, Boolean A_4)
at EvoPdf.HtmlToPdfConverter.?(Stream A_0, String A_1, String A_2, String A_3, String A_4, Boolean A_5)
at EvoPdf.HtmlToPdfConverter.ConvertHtmlToStream(String htmlString, String baseUrl, String internalLinksBaseUrl, Stream outPdfStream)
at EvoPdf.HtmlToPdfConverter.ConvertHtmlToStream(String htmlString, String baseUrl, Stream outPdfStream)
The project was built as 64 bit binary. It runs on an IIS and we checked that it really runs in a 64 bit pool. The application itself uses roughly 200 - 400 MB memory and has lots of free memory on the machine. So this shouldn't be a problem.
Our html files aren't really fancy and it happens with small pages as well as on big pages.
var evo = new EvoPdf.HtmlToPdfConverter();
//...
using (var stream = new MemoryStream())
{
string baseUrl = "";
evo.ConvertHtmlToStream(html, baseUrl, stream);
return stream.ToArray();
}
The said domain logic classes are inserted with transient lifetime and all dependencies (pdf creation included) as well. We checked captive dependencies, but found none.
Right know we don't know what to do, because the exception happens just occasionally and we cannot reproduce this on the development machines.
Any ideas on what to do?