Skip to content

Commit 661f4b2

Browse files
sync: coreth PR #1173: fix: free memory used by proposals in firewood (#1782)
Co-authored-by: Joachim Brandon LeBlanc <brandon@leblanc.codes>
1 parent c8a3424 commit 661f4b2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

triedb/firewood/database.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,10 +376,15 @@ func (db *Database) Close() error {
376376
db.proposalLock.Lock()
377377
defer db.proposalLock.Unlock()
378378

379-
// We don't need to explicitly dereference the proposals, since they will be cleaned up
380-
// within the firewood close method.
379+
// before closing, we must deference any outstanding proposals to free the
380+
// memory owned by firewood (outside of go's memory management)
381+
for _, pCtx := range db.proposalTree.Children {
382+
db.dereference(pCtx)
383+
}
384+
381385
db.proposalMap = nil
382386
db.proposalTree.Children = nil
387+
383388
// Close the database
384389
return db.fwDisk.Close()
385390
}

0 commit comments

Comments
 (0)