gorocksdb icon indicating copy to clipboard operation
gorocksdb copied to clipboard

memory leak in get API

Open heidawei opened this issue 7 years ago • 3 comments

we need free slice after get from rocksdb, and copy data before return ????

heidawei avatar Jun 14 '18 02:06 heidawei

appears so, I was getting data corruption on my Get calls and had to add a copy. Seems to have solved the corruption issue

result, err := db.Get(ro, key)
	if err != nil {
		result.Free()
		panic(err.Error())
	}
	tmpData := make([]byte, len(result.Data()))
	copy(tmpData, result.Data())
	defer result.Free()
        return tmpData

jiminoc avatar Dec 06 '18 22:12 jiminoc

What about using GetBytes?

hkparker avatar Oct 07 '19 20:10 hkparker

@jiminoc This free() bothered me for a few days, but it worked. Otherwise, memory will grow dramatically

whiteCcinn avatar Apr 16 '21 08:04 whiteCcinn