I’m attempting to use Aspose.Email.Printing.MailPrinter to convert a .MSG to a PDF through an intermediate XPS file. (I’ve already tried the MHTML route with other issues).
There appears to be a severe handle and/or memory leak when using the MailPrinter to create either a XPS or TIFF file. Running this simplified example will cause the handle count and memory to increase without being collected. We’ve found about 5000 iterations is enough to make the system unstable (can no longer open task manager, etc…)
public static void HandleLeak()
{
for (int i = 0; i < 5000; i++)
{
using (var ms = new MemoryStream())
{
using (var message = new MailMessage(“me@localhost”, “you@localhost”, “test subject”, “test body”))
{
var printer = new MailPrinter() {FormattingFlags = MessageFormattingFlags.MailInfo};
printer.Print(message, ms, PrintFormat.XPS);
}
}
}
}