For databases that are mainly written, the write efficiency becomes unstable when the MongoDB memory is full.
At this time, you need to release the memory (you can try dB. runcommand ({closealldatabases: 1 }).
The following C #CodeIt can be used to release memory on a regular basis. When using it, replace the path with the path of your server, and modify the release frequency.
Technorati label: MongoDB
Class program {static void main (string [] ARGs) {While (true) {New thread (delegate () {console. writeline ("START release"); cmd (@ "Echo is starting mongodbd: cd d: \ MongoDB \ bin1_use admindb. runcommand ({closealldatabases: 1}) "," bye "); console. writeline ("Release completed ");}). start (); // three-hour thread. sleep (3*3600*1000 );}}/// /// Execute the command /// /// ///
Static void cmd (string cmd, string end) {Process = new process {startinfo = {filename = "cmd.exe", useshellexecute = false, redirectstandardinput = true, redirectstandardoutput = true, redirectstandarderror = true, createnowindow = true}; process. start (); process. standardinput. autoflush = true; process. standardinput. writeline (CMD); process. standardinput. writeline ("exit"); var output = ""; While (! (Output = process. standardoutput. readline ()). contains (end) {console. writeline (output);} console. writeline (output); If (process. hasexited = false) // process is still running. // test to see if the process is hung up. if (process. responding) // process was responding; close the main window. process. closemainwindow (); else // process was not responding; force the process to close. process. kill (); process. close ();}}