diff --git a/triedb/firewood/database.go b/triedb/firewood/database.go index 45fa0d0423..df46b84a10 100644 --- a/triedb/firewood/database.go +++ b/triedb/firewood/database.go @@ -376,10 +376,15 @@ func (db *Database) Close() error { db.proposalLock.Lock() defer db.proposalLock.Unlock() - // We don't need to explicitly dereference the proposals, since they will be cleaned up - // within the firewood close method. + // before closing, we must deference any outstanding proposals to free the + // memory owned by firewood (outside of go's memory management) + for _, pCtx := range db.proposalTree.Children { + db.dereference(pCtx) + } + db.proposalMap = nil db.proposalTree.Children = nil + // Close the database return db.fwDisk.Close() }