Based on our observation while benchmarking badgerDB, we saw heavy memory retention with badgerDB on linux as compared to on freebsd. Digging further into this, we saw that for linux, badgerDB is clubbing munmap() and mmap() calls for vlog file into a single mremap() call. mremap(), based on our observations is somehow retaining a portion of mapped file in memory and not freeing the pages when system is stressed for memory.
We would like to know if there is an obvious advantage of using mremap on linux which we are missing because our findings suggests that badgerDB behaves much better in terms of memory utilisation when vlog file is munmap()ed and mmap()ed when the file is full.