Leveldb limit testing - limit Memory used by a pro

2019-09-05 22:57发布

I'm currently benchmarking an application built on Leveldb. I want to configure it in such a way that the key-values are always read from disk and not from memory.
For that, I need to limit the memory consumed by the program.
I'm using key-value pairs of 100 bytes each and 100000 of them, which makes their size equal to 10 MB. If I set the virtual memory limit to less than 10 MB using ulimit, I can't even run the command Makefile.

1) How can I configure the application so that the key value pairs are always fetched from the disk?

2) What does ulimit -v mean? Does limiting the virtual memory translate to limiting the memory used by the program on RAM?

1条回答
2楼-- · 2019-09-05 23:35

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()) {
    ...
  }
查看更多
登录 后发表回答