Garbage Collection In CollectionBase Classes
Posted on 2007-11-29
I'm having a huge problem. I have created a CollectionBase class called Photos.
Photos is a collection of Class Photo. and holds (go figure) a photo and some information about the photo (name, size and such)
The photos are stored as Blob data in a SQL database and Photos has a load method that loads the collection from the DB.
Ok... as a test i tried this:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Photos As New colPhotos
Dim icount As Integer
For icount = 1 To 10
Me.Label1.Text = Photos.Count
Me.Label1.Text = "Done"
Now when I run this I watch the windows task manager. The first iteration uses up about 15mb of memory, The problem is that each susequent iteration uses another 15mb of memory.
when the loop finishes i've got 150+ mb of memory used that will not be returned until i close the program. In this test case a single form.
Nothing i have tried will release the memory untill the program exits.... I even tried waiting an hour to see if GC would eventually release it.
Tried Early binding .. LateBinding
I've even tried :
Why is VB holding onto that memory. I'm not creating another instance of the object (at least I think I'm not)
Anyone know how to get VB to release the memory.
I have several of these classes in an app and I noticed over time the mem utilization going Up...Up..Up