我突然得到了運行在不同機器上的兩個程序的內存異常錯誤,即使它看起來有足夠的內存,它仍然顯示出來。我在程序中創建了多個線程,所以不確定這是否適合這個論壇,但它可能是與Visual Studio有關的其他內容,或者它肯定是內存問題。一個程序在我的桌面上使用2 GB內存的visual studio 2008運行。另一個使用Visual Basic 2008 Express在帶有4 GB RAM的Windows 2003服務器上運行。 現在模塊接受一個大的xml文件,讀入一個字符串,然後拆分並存儲在一個字符串數組中。現在大塊的數量可以達到10000個。現在我知道這很大,但我已經運行了一個多月,從未遇到過這個問題。我注意到的唯一其他可能的相關問題是我的硬盤空間不足,但很快就通過清理解決了問題。哦,是的,我的機器的處理器是雙核2.13 GHZ。 這是一個控制檯程序,它可以創建多個web請求,但只有一個特定的模塊出現內存問題,正如我上面所解釋的那樣。類型'System.OutOfMemoryException'的異常被拋出
Public Shared Function textLoad(ByVal _html As String) As Boolean
Try
//_html is the filestream that was read in
Dim defaultHeading = "xmlns:gnip=""http://www.gnip.com/schemas/2010"" xmlns=""http://www.w3.org/2005/Atom"""
Dim header_of_xml As String = "<?xml version=""1.0"" encoding=""utf-8""?>" & vbNewLine & "<entry " & defaultHeading & ">"
Dim footer_of_xml As String = "</entry>"
Dim entry As String = String.Empty
Dim xrs As XmlReaderSettings = New XmlReaderSettings()
Dim dupeArray As New ArrayList
Dim stringSplitter() As String = {"</entry>"}
//split the file content based on the closing entry tag
sampleResults = Nothing
sampleResults = _html.Split(stringSplitter, StringSplitOptions.RemoveEmptyEntries)
entryResults.Clear()
If getEntryId(sampleResults) Then
// the following loops seem clumsy but I wanted to dedupe the lists to //ensure that I am not adding duplicate entries and I do this by going to the getEntryID //method and extracting the ids and then comparing them below
For i As Integer = 0 To sampleResults.Count - 1
For j As Integer = 0 To idList.Count - 1
If sampleResults(i).Contains(idList.Item(j)) AndAlso Not dupeArray.Contains(idList.Item(j)) Then
dupeArray.Add(idList.Item(j))
entry = sampleResults(i)
我沒看任務管理器,用於識別該程序所使用的資源,這是怎麼回事:
Parser.exe CPU = 34 MEM使用率= 349,500ķ
沒有別的密集運行
編輯_ -
想通了EXAC tly出現問題的原因:
**sampleResults = _html.Split(stringSplitter, StringSplitOptions.RemoveEmptyEntries)**
任何人都可以注意到這個問題?
這可能屬於對stackoverflow.com,但我沒有足夠的代表投票關閉。 –
@TomasLycken你可以隨時舉報 - >國旗 - >不屬於這裏 - >屬於X. – Sathya
@vbNewbie請提供更多詳細信息 - 這是你正在構建的應用程序嗎?你的系統規格是什麼 - 即處理器,RAM等。 – Sathya