I'm using mongodb aggregate to sample documents from a large collection.
https://docs.mongodb.com/manual/reference/operator/aggregation/sample/
After making several consecutive calls, I see the memory of mongodb climbing up, and after around the 12th call, it crashes with OutOfMemory error.
How can I tell Mongodb to free up the memory after it has finished processing a query?