MongoDB crashes due to out of memory exception

I process a huge amount of data in MongoDB and recently my server hosting the data lake consistently crashes when data processing is done. The log files indicate that it is out of memory with the following error message:

[conn29] out of memory.

This is weird because there is still a lot of space on the disk of my server so I am confused why mongoDB crashes with this error. Previously, I have been running the compact command to reclaim any free space after the processing is done. Is it possible that this just, somehow, takes space away from mongoDB gradually and give it back to the OS, hence the out of memory exception? How can I monitor the amount of memory available for mongoDB?