tecbot / gorocksdb

gorocksdb is a Go wrapper for RocksDB
http://rocksdb.org
MIT License
940 stars 269 forks source link

Possible memory leak when iterating over database with MergeOperator enabled #144

Open vitalyisaev2 opened 6 years ago

vitalyisaev2 commented 6 years ago

We faced with memory leak with one of our applications, which periodically iterates over whole Rocksdb database to compute some statistics. We also use MergeOperator implemented in Go, and it turns out that the memory allocated within MergeOperator is never freed.

Please see this repository for the further infomation: https://github.com/vitalyisaev2/gorocksdb_merge_operator_issue

Picture of heap profile to grab your attention: heap profile

NgaiShunChan commented 5 years ago

In file gorocksdb.c, an empty implementation of function gorocksdb_filterpolicy_delete_filter and gorocksdb_mergeoperator_delete_value preventing default function free to be called. See rocksdb/blob/master/db/c.cc Which may lead to memory leak.

vitalyisaev2 commented 5 years ago

@NgaiShunChan thanks for the tip, I'm not sure I have understood it right now, but I'll try to make a research