Java程序修改代码
??????????????
void UpdateMemmory() { try { RegistryKey root = Registry.LocalMachine; RegistryKey software = root.OpenSubKey("SOFTWARE", true); RegistryKey asf = software.OpenSubKey("Apache Software Foundation", true); RegistryKey pru = asf.OpenSubKey("Procrun 2.0", true); //RegistryKey tl = pru.OpenSubKey("tomcatloan", true); RegistryKey tl = pru.OpenSubKey(CommonMethod.GetTomcatName(), true); RegistryKey Parameters = tl.OpenSubKey("Parameters", true); RegistryKey java = Parameters.OpenSubKey("Java", true); string[] strarray = java.GetValue("Options") as string[]; if (strarray != null) { bool flag = true; ArrayList al = new ArrayList(); for (int i = 0; i < strarray.Length; i++) { //if (strarray[i] == "-Xrs –Xms512m –Xmx1024m") if(strarray[i].StartsWith("-Xrs –Xms512m –Xmx1024m")) { flag = false; } al.Add(strarray[i]); } if (flag) { al.Add("-Xrs –Xms512m –Xmx1024m"); al.Add("-XX:PermSize=256M"); al.Add("-XX:MaxPermSize=256M"); java.SetValue("Options", (string[])al.ToArray(typeof(string)), RegistryValueKind.MultiString); } } } catch { } }
?
al.Add("-XX:PermSize=256M");
al.Add("-XX:MaxPermSize=256M");
上边这两句很重要,是设置tomcat的非堆内存大小,什么事非堆内存,自己可以百度。同时写进注册表的参数一定是分行的,写成一行不行。
?
文章转载自:http://www.cnblogs.com/zjBoy/archive/2013/01/04/2844091.html