Browse Source

Memory optimization: dispose native objects when related to document content injected to the TextBlock element

Marcin Ziąbek 9 months ago
parent
commit
d19753758f
1 changed files with 4 additions and 0 deletions
  1. 4 0
      Source/QuestPDF/Elements/Text/TextBlock.cs

+ 4 - 0
Source/QuestPDF/Elements/Text/TextBlock.cs

@@ -54,6 +54,10 @@ namespace QuestPDF.Elements.Text
         public void Dispose()
         {
             Paragraph?.Dispose();
+            
+            foreach (var textBlockElement in Items.OfType<TextBlockElement>())
+                textBlockElement.Element.ReleaseDisposableChildren();
+            
             GC.SuppressFinalize(this);
         }