最佳解答者
Any way to Reduce Memory Usage on VB.Net Application

問題
-
Hi
I am implementing a VB.Application, in which I need to use a lot of DataTable, ArrayList ...etc. To process the data. E.g. Every 5 mins
Could you give me some suggestion about how to reduce the system memory usage?
Will Datatable = nothing release the used memory from data table?
Thanks in Advance2008年5月16日 下午 03:24
解答
-
sorry guys...
I don't know there has no "null" in vb, my fault.
ChiYau:
Here is a simple sample:
Code SnippetDim al As ArrayList
al = New ArrayList();'Call Clear before set nothing
al.Clear()
al = NothingDim dt As DataTable
dt = New DataTable()'Call Dispose before set nothing
dt.Dispose()
dt = NothingMake sure there has no reference:
Code SnippetDim al As ArrayList
al = New ArrayList()
al.Add("a")
al.Add("b")
al.Add("c")
al.Add("d")
al.Add("e")
al.Add("f")Dim s As String
s = CType(al(0), String)
s = Nothing
'Set the reference to nothing before call Clear
al.Clear()
'Call Clear before set nothing
al = Nothing2008年5月19日 上午 09:52
所有回覆
-
Hi Allen & Jacky
Thanks for your information,
After I set the variable to Nothing, Shall I call Dispose method as well?
To Jacky: What do you mean by "make sure you didn't reference anymore to the DataTable, ArrayList"?
You mean do not pass that Datatable object into another method?
In VB.Net I i cannot use tbl=null, do you mean to user tbl.clear()?
Many thanks2008年5月19日 上午 07:25 -
sorry guys...
I don't know there has no "null" in vb, my fault.
ChiYau:
Here is a simple sample:
Code SnippetDim al As ArrayList
al = New ArrayList();'Call Clear before set nothing
al.Clear()
al = NothingDim dt As DataTable
dt = New DataTable()'Call Dispose before set nothing
dt.Dispose()
dt = NothingMake sure there has no reference:
Code SnippetDim al As ArrayList
al = New ArrayList()
al.Add("a")
al.Add("b")
al.Add("c")
al.Add("d")
al.Add("e")
al.Add("f")Dim s As String
s = CType(al(0), String)
s = Nothing
'Set the reference to nothing before call Clear
al.Clear()
'Call Clear before set nothing
al = Nothing2008年5月19日 上午 09:52 -
Hi Allen
On 8 Oct, after first day of TechEd, we are going to host a community gathering where you can have a drink and network with your peers in the industry, please RSVP with me at hkdevcom@microsoft.com.
Event Details
Date: 8 Oct, 2008 (Wednesday)
Time: 7pm to 9pm
Venue: Cenna Bar & Lounge (銅鑼灣軒尼詩道525號恒和鑽石大廈23樓)
Thanks and looking forward to seeing you at the event!
Cheers,
Angela Ip (MSHK)
2008年9月25日 上午 08:26