M
Michael M.
HI all,
When I add items to a Listview control, then clearing the items and adding
more items my program seems to allocate a few KB of data and then not free
the Memory. I noticed this about half way through writing a program and
it's driving me a bit mad. I have posted a sub function below that I used
to test this problem:
The Sub is called every 4 seconds by a timer object, every 4 the seconds the
memory usage of the program is incremented by arround 40K. if I leave it
running for 20 minutes it can get as large as 50 megabytes.
Test setup:
VB.net 2005 Express, with .net framework 2 on XP Pro service pack 2.
P4 CPU arround 3 Ghz
1 GIG of DDR memory.
Sub AddProcessData()
ListView1.items.clear()
For Each oProcess As Process In Diagnostics.Process.GetProcesses
Dim lv As New ListViewItem
Try
lv.Text = oProcess.MainModule.ModuleName
lv.SubItems.Add(oProcess.Id.ToString)
lv.SubItems.Add(oProcess.StartTime.ToString)
ListView1.Items.Add(lv)
Catch ex As Exception
End Try
lv = Nothing
oProcess = Nothing
Next
End Sub
Anyone know what's happening here? calling GC.Collect does not help either.
I am new to .net programming so there is a good chance I am overlooking
something obvious
Regards,
Mike.
When I add items to a Listview control, then clearing the items and adding
more items my program seems to allocate a few KB of data and then not free
the Memory. I noticed this about half way through writing a program and
it's driving me a bit mad. I have posted a sub function below that I used
to test this problem:
The Sub is called every 4 seconds by a timer object, every 4 the seconds the
memory usage of the program is incremented by arround 40K. if I leave it
running for 20 minutes it can get as large as 50 megabytes.
Test setup:
VB.net 2005 Express, with .net framework 2 on XP Pro service pack 2.
P4 CPU arround 3 Ghz
1 GIG of DDR memory.
Sub AddProcessData()
ListView1.items.clear()
For Each oProcess As Process In Diagnostics.Process.GetProcesses
Dim lv As New ListViewItem
Try
lv.Text = oProcess.MainModule.ModuleName
lv.SubItems.Add(oProcess.Id.ToString)
lv.SubItems.Add(oProcess.StartTime.ToString)
ListView1.Items.Add(lv)
Catch ex As Exception
End Try
lv = Nothing
oProcess = Nothing
Next
End Sub
Anyone know what's happening here? calling GC.Collect does not help either.
I am new to .net programming so there is a good chance I am overlooking
something obvious
Regards,
Mike.