mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-30 23:45:28 +08:00
Fix rocksdb_kv memory leak (#8743)
Signed-off-by: fishpenguin <kun.yu@zilliz.com>
This commit is contained in:
parent
54a4e2cbeb
commit
93fa86daf2
@ -135,6 +135,7 @@ func (kv *RocksdbKV) MultiLoad(keys []string) ([]string, error) {
|
||||
return []string{}, err
|
||||
}
|
||||
values = append(values, string(value.Data()))
|
||||
value.Free()
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
@ -154,7 +155,7 @@ func (kv *RocksdbKV) MultiSave(kvs map[string]string) error {
|
||||
return errors.New("Rocksdb instance is nil when do MultiSave")
|
||||
}
|
||||
writeBatch := gorocksdb.NewWriteBatch()
|
||||
defer writeBatch.Clear()
|
||||
defer writeBatch.Destroy()
|
||||
for k, v := range kvs {
|
||||
writeBatch.Put([]byte(k), []byte(v))
|
||||
}
|
||||
@ -207,7 +208,7 @@ func (kv *RocksdbKV) MultiRemove(keys []string) error {
|
||||
return errors.New("Rocksdb instance is nil when do MultiRemove")
|
||||
}
|
||||
writeBatch := gorocksdb.NewWriteBatch()
|
||||
defer writeBatch.Clear()
|
||||
defer writeBatch.Destroy()
|
||||
for _, key := range keys {
|
||||
writeBatch.Delete([]byte(key))
|
||||
}
|
||||
@ -221,7 +222,7 @@ func (kv *RocksdbKV) MultiSaveAndRemove(saves map[string]string, removals []stri
|
||||
return errors.New("Rocksdb instance is nil when do MultiSaveAndRemove")
|
||||
}
|
||||
writeBatch := gorocksdb.NewWriteBatch()
|
||||
defer writeBatch.Clear()
|
||||
defer writeBatch.Destroy()
|
||||
for k, v := range saves {
|
||||
writeBatch.Put([]byte(k), []byte(v))
|
||||
}
|
||||
@ -238,7 +239,7 @@ func (kv *RocksdbKV) DeleteRange(startKey, endKey string) error {
|
||||
return errors.New("Rocksdb instance is nil when do DeleteRange")
|
||||
}
|
||||
writeBatch := gorocksdb.NewWriteBatch()
|
||||
defer writeBatch.Clear()
|
||||
defer writeBatch.Destroy()
|
||||
if len(startKey) == 0 {
|
||||
iter := kv.DB.NewIterator(kv.ReadOptions)
|
||||
defer iter.Close()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user