Skip to content

Commit 224d7c9

Browse files
authored
fix: free memory used by proposals in firewood (#1173)
1 parent 5e785ce commit 224d7c9

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
@@ -378,10 +378,15 @@ func (db *Database) Close() error {
378378
db.proposalLock.Lock()
379379
defer db.proposalLock.Unlock()
380380

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

0 commit comments

Comments
 (0)