Mongodb – Reset mongo cache memory for test perfomance – windows

mongodbwindows

recently i'm working on mongo db and I'm trying to check the performance of mongodb with 2 million record. I need to clear cache every time I start the test. I don't want to restart the computer/server each time I want to run the test. I tried to clear collections cache but the result wasn't as I expected. Is there a way to clear cache like the way exist in linux ?

Best Answer

  1. stop mongod

  2. sh -c "sync; echo 3 > /proc/sys/vm/drop_caches"

  3. start mongod

stop mongod: Stops the database service. sh -c "sync; echo 3 > /proc/sys/vm/drop_caches": write any data stored in memory to disk. start mongod: Start the database again.