I ran the function repeatedly with memory usage monitored. The memory usage rose with
- Private Function ReadDatarowCollection(Code As String, Year As UShort, Quarter As Byte) As HTMLCollection
- Dim a As New HTMLDocument("http://vip.stock.finance.sina.com.cn/corp/go.php/vMS_FuQuanMarketHistory/stockid/" & Code & ".phtml?year=" & Year & "&jidu=" & Quarter)
- Dim b As HTMLCollection = DirectCast(a.GetElementById("FundHoldSharesTable"), HTMLTableElement).Rows
- Return b
- End Function
Dim a As New HTMLDocument, but didn't drop when
a.Dispose(). The usage remained the same when the function was called again, and rose again for the New HTMLDocument, then still didn't drop when Dispose().
I think it’s very likely a memory leak. Dispose() doesn’t work. In application the function will be called thousands of times, so such leak is very serious, causing GBs of memory waste. What should I do?