Maybe it should, but we've been developing this as UI control that has one or two on-screen instances, that users might occasionally export to PDF. Most of the WeakReferences that grow the heap are WPF internals anyway from what we can tell, and .NET will recycle them when memory needed.
If you are looking to create a PDF generation service for large number of off-screen diagrams with lower memory footprint, you could try the diagramming.dll from our ASP.NET and WinForms controls (it's shared between them); this same test never takes more than 50MB with it -
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
var rand = new Random();
diagrams = new List<Diagram>();
for (int j = 0; j < 40; j++)
{
var diag = new Diagram();
for (int i = 0; i < 100; i++)
{
var shapeNode = new ShapeNode()
{
Shape = new Shape(new ElementTemplate[]
{
new LineTemplate(0, 0, 100, 0),
new LineTemplate(100, 0, 100, 100),
new LineTemplate(100, 100, 0, 100),
}, System.Drawing.Drawing2D.FillMode.Alternate),
};
shapeNode.AddLabel(new NodeLabel() { Text = "Test" });
diag.Nodes.Add(shapeNode);
diag.Nodes.Last().Move(rand.Next(0, 1000), rand.Next(0, 1000));
}
diag.ResizeToFitItems(5);
diagrams.Add(diag);
}
}
public List<Diagram> diagrams { get; set; }
private void button1_Click(object sender, EventArgs e)
{
var exporter = new PdfExporter();
foreach (var diag in diagrams)
exporter.Export(diag, "diagram.pdf");
}
}
https://www.nuget.org/packages/MindFusion.Diagramming/Regards,
Slavcho
Mindfusion