Quite often, especially for benchmarks, I am trying to limit
  available memory for a database server (usually for MySQL, but
  recently for MongoDB also). This is usually needed to test
  database performance in scenarios with different memory limits. I
  have physical servers with the usually high amount of memory
  (128GB or more), but I am interested to see how a database server
  will perform, say if only 16GB of memory is available.
  And while InnoDB usually respects the setting of
  innodb_buffer_pool_size in O_DIRECT mode (OS cache is not being
  used in this case), more engines (TokuDB for MySQL, MMAP,
  WiredTiger, RocksDB for MongoDB) usually get benefits from OS
  cache, and Linux kernel by default is generous enough to allocate
  as much memory as available. There I should note that while
  TokuDB (and TokuMX for MongoDB) supports DIRECT mode (that is
  bypass OS cache), we found there is a performance gain if OS
  cache is used for compressed pages.
 …
[Read more]