mongoDB 内存如何控制
当我用GridFS时候把文件存储到mongoDB中时,机器的内存不断增长,怎么控制一下内存使用?--------------------编程问答-------------------- 目前的办法就是调一下批处理来释放或者如下:
class Program
02 {
03 static void Main(string[] args)
04 {
05 while (true)
06 {
07 new Thread(delegate()
08 {
09 Console.WriteLine("开始释放");
10 Cmd(@"echo 正在启动MongoDB
11 d:
12 cd D:\mongodb\bin
13 mongo
14 use admin
15 db.runCommand({closeAllDatabases:1})
16 ", "bye");
17 Console.WriteLine("释放完成");
18 }).Start();
19
20 // 三小时
21 Thread.Sleep(3 * 3600 * 1000);
22 }
23 }
24
25 /// <SUMMARY>
26 /// 执行命令
27 /// </SUMMARY>
28 /// <PARAM name="cmd" /></PARAM>
29 /// <RETURNS></RETURNS>
30 static void Cmd(string cmd, string end)
31 {
32 Process process = new Process
33 {
34 StartInfo =
35 {
36 FileName = "cmd.exe",
37 UseShellExecute = false,
38 RedirectStandardInput = true,
39 RedirectStandardOutput = true,
40 RedirectStandardError = true,
41 CreateNoWindow = true
42 }
43 };
44 process.Start();
45 process.StandardInput.AutoFlush = true;
46 process.StandardInput.WriteLine(cmd);
47 process.StandardInput.WriteLine("exit");
48 var outPut = "";
49
50 while (!(outPut = process.StandardOutput.ReadLine()).Contains(end))
51 {
52 Console.WriteLine(outPut);
53 }
54
55 Console.WriteLine(outPut);
56
57 if (process.HasExited == false)
58 //Process is still running.
59 //Test to see if the process is hung up.
60 if (process.Responding)
61 //Process was responding; close the main window.
62 process.CloseMainWindow();
63 else
64 //Process was not responding; force the process to close.
65 process.Kill();
66
67 process.Close();
68 }
69 }
--------------------编程问答-------------------- 控制不了,内存会被全部占用的 --------------------编程问答-------------------- 操作系统本身对内核级“内存映射文件”技术做了很多优化,占用内存再多,你的其它应用程序的性能也基本上也不受影响。你测试一下看看。 --------------------编程问答-------------------- 硬件升级也是一个办法,装64位操作系统
补充:.NET技术 , .NET技术前瞻