Skip to content

memory leak in crypto/merkle (?) #3313

@ebuchman

Description

@ebuchman

Running a default single node causes the memory to grow.

Inspecting the difference in heap dumps as the memory grows suggests there's a leak in the use of the Merkle tree.

Running a very simple test confirms this.

For instance this code:

package main

import (
	"fmt"
	"net/http"
	_ "net/http/pprof"
	"runtime"

	"github.com/tendermint/tendermint/crypto/merkle"
)

func main() {
	runtime.MemProfileRate = 1
	fmt.Println("vim-go")
	list := [][]byte{
		[]byte("hello"),
		[]byte("goodbye"),
		[]byte("ok"),
	}
	myFunc(list)
	runtime.GC()
	http.ListenAndServe("localhost:7070", nil)
	fmt.Println(list)
}

func myFunc(list [][]byte) {
	merkle.SimpleHashFromByteSlices(list)
}

Leaves many of these such entries in the heap profile:

0: 0 [1: 80] @ 0x1408c93 0x140c888 0x140ceff 0x140cda2 0x102f167 0x105d5a1
#	0x1408c92	github.com/tendermint/tendermint/crypto/merkle.innerHash+0x162			/Users/ethanbuchman/programming/goApps/src/github.com/tendermint/tendermint/crypto/merkle/hash.go:20
#	0x140c887	github.com/tendermint/tendermint/crypto/merkle.SimpleHashFromByteSlices+0x137	/Users/ethanbuchman/programming/goApps/src/github.com/tendermint/tendermint/crypto/merkle/simple_tree.go:19
#	0x140cefe	main.myFunc+0x3e								/Users/ethanbuchman/programming/goApps/src/github.com/tendermint/tendermint/pprof/main.go:27
#	0x140cda1	main.main+0x1f1									/Users/ethanbuchman/programming/goApps/src/github.com/tendermint/tendermint/pprof/main.go:20
#	0x102f166	runtime.main+0x206								/Users/ethanbuchman/goRoot/1.11.5/src/runtime/proc.go:201

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions