MongoDB regularly releases memory

Source: Internet
Author: User

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 ();}}
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.