上一篇隨筆中寫過64位程序與32位程序(https://www.cnblogs.com/Heavystudio/p/11059033.html),最近開始正式在項目中大量實現了,但又出現了一個問題,html
因爲32位程序中還調用了大量dll,致使每次調用時啓動與關閉時都拖泥帶水,導致出現運行異常runtime error R6016 - not enough space for thread data,經嘗試發現,ui
這個異常會隨運行內存變化而變化,根本緣由是由於屢次調用32位程序後,致使沒有內存空間建立新的進程。spa
經查找資料顯示,這個問題常常出如今由C、C++、Vb6等寫的代碼中,而像C#中有自動內存管理,因此通常不會出現此類問題。htm
64位程序以下:blog
process.Kill();馬上殺死一切由這個32位程序啓動的進程,用一次,殺一次,不影響下次使用
static void Main(string[] args) { //建立refpropPipe進程 Process process = new Process(); //將refpropPipe.exe放在與refprop64Hv相同路徑下,相對路徑引用 process.StartInfo.FileName = @"C:\Users\Administrator\source\repos\refpropPipe\refpropPipe\bin\Debug\refpropPipe.exe"; //process.StartInfo.FileName = "refpropPipe.exe"; process.Start(); double value = 0; //向refpropPipe發送調用信息,即查詢輸入變量值 using (NamedPipeClientStream pipeClientStream = new NamedPipeClientStream("request")) { pipeClientStream.Connect(); string input = Method + "," + FluidName + "," + InpCode + "," + Units + "," + Prop1 + "," + Prop2; using (StreamWriter writer = new StreamWriter(pipeClientStream)) { writer.WriteAsync(input); } } //接收refpropPipe返回的信息,即查詢結果 using (NamedPipeClientStream pipeClientStream = new NamedPipeClientStream("respose")) { pipeClientStream.Connect(); using (StreamReader reader = new StreamReader(pipeClientStream)) { string val = reader.ReadToEnd(); value = Convert.ToDouble(val); } } //process.WaitForExit(); //process.Close(); //不在等待了,直接殺死進程,免得拖泥帶水,快哉快哉 process.Kill(); }