fix(memory): fix possible memory leak and add better tests

This commit is contained in:
Antoine Aflalo
2025-02-13 20:02:45 -05:00
parent 25cd4585b7
commit efe1696bfa
4 changed files with 47 additions and 20 deletions

View File

@@ -17,3 +17,11 @@ type PageContainer struct {
func NewContainer(Page *Page, img image.Image, format string, isToBeConverted bool) *PageContainer {
return &PageContainer{Page: Page, Image: img, Format: format, IsToBeConverted: isToBeConverted}
}
// Close releases resources held by the PageContainer
func (pc *PageContainer) Close() {
pc.Image = nil
if pc.Page != nil && pc.Page.Contents != nil {
pc.Page.Contents.Reset()
}
}