簡體   English   中英

錯誤處理 system.outofmemoryexception

[英]Error handling system.outofmemoryexception

我正在使用多線程將內容發布到 1 url。 我的錯誤是當我運行 300 個線程時,在 10 到 15 分鍾后,我將被推出並收到消息“system.outofmemoryexception”。 據我了解,我的電腦配置是:Ram 32G,12核,24線程……我是新手,不知道怎么處理? 你能幫助我嗎。 無論如何我要感謝。

代碼:

int sothread = 100; 
for (int ii = 0; ii < sothread; ii++) 
    Thread t2 = new Thread(() => { 
        while (true) {
            string url = "https://phamnhi.net"; 
            string data = "id=123213&view=333"; 
            html = PostData(http, url, data, "application/x-www-form-urlencoded; charset=UTF-8").ToString(); 
            try { 
                if (html.Contains("OK")) { 
                    row.Cells[status].Value = "ok..."; 
                    Thread.Sleep(20000); 
                    http.Close(); 
                }
            } catch (OverflowException) { break; } 
        } 
    });
     t.IsBackground = true;
     t.Start();
     Thread.Sleep(1000); 
} 

聽起來您需要在程序執行后釋放程序的資源。 如果每個線程都在未完成的情況下完成更多工作,那么您最終將用完 memory。 請發布一些代碼以供分析。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM