leveldb 降低内存使用

创建日期: 2024-11-13 15:32 | 作者: 风波 | 浏览次数: 16 | 分类: KV数据库

来源:https://stackoverflow.com/questions/38469966/leveldb-limit-testing-limit-memory-used-by-a-program

Perhaps there is no need in reducing available memory, but simply disable cache as described here:

  leveldb::ReadOptions options;
  options.fill_cache = false;
  leveldb::Iterator* it = db->NewIterator(options);
  for (it->SeekToFirst(); it->Valid(); it->Next()) {
    ...
  }

设置选项 options.fill_cache = false; 可以降低在遍历索引时的内存使用量。但是呢,经过测试,在遍历过程中,并没有少申请内存,而是在遍历结束后,内存自动下降了很多。

16 浏览
0 评论