diff --git a/build/ci.go b/build/ci.go index 7440b2f36e..8c34d62fe3 100644 --- a/build/ci.go +++ b/build/ci.go @@ -289,6 +289,7 @@ func doTest(cmdline []string) { coverage = flag.Bool("coverage", false, "Whether to record code coverage") verbose = flag.Bool("v", false, "Whether to log verbosely") race = flag.Bool("race", false, "Execute the race detector") + short = flag.Bool("short", false, "Pass the 'short'-flag to go test") ) flag.CommandLine.Parse(cmdline) @@ -312,6 +313,9 @@ func doTest(cmdline []string) { if *race { gotest.Args = append(gotest.Args, "-race") } + if *short { + gotest.Args = append(gotest.Args, "-short") + } packages := []string{"./..."} if len(flag.CommandLine.Args()) > 0 { diff --git a/core/blockchain.go b/core/blockchain.go index ffe0367ef8..a1ee8f443a 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -909,6 +909,7 @@ func (bc *BlockChain) Stop() { log.Error("Failed to journal state snapshot", "err", err) } } + bc.snaps.Release() } // Ensure the state of a recent block is also stored to disk before exiting. diff --git a/core/state/snapshot/disklayer.go b/core/state/snapshot/disklayer.go index f1f835d587..a99afc136b 100644 --- a/core/state/snapshot/disklayer.go +++ b/core/state/snapshot/disklayer.go @@ -45,6 +45,16 @@ type diskLayer struct { lock sync.RWMutex } +// Release releases underlying resources; specifically the fastcache requires +// Reset() in order to not leak memory. +// OBS: It does not invoke Close on the diskdb +func (dl *diskLayer) Release() error { + if dl.cache != nil { + dl.cache.Reset() + } + return nil +} + // Root returns root hash for which this snapshot was made. func (dl *diskLayer) Root() common.Hash { return dl.root diff --git a/core/state/snapshot/snapshot.go b/core/state/snapshot/snapshot.go index ac70ba8275..36b8179cc8 100644 --- a/core/state/snapshot/snapshot.go +++ b/core/state/snapshot/snapshot.go @@ -668,6 +668,13 @@ func diffToDisk(bottom *diffLayer) *diskLayer { return res } +// Release releases resources +func (t *Tree) Release() { + if dl := t.disklayer(); dl != nil { + dl.Release() + } +} + // Journal commits an entire diff hierarchy to disk into a single journal entry. // This is meant to be used during shutdown to persist the snapshot without // flattening everything down (bad for reorgs).