I would think that the garbage collector is possibly taking longer to collect this class because it contains an instance event.
Your object IS freed, it just appears to take longer. On Mon, Sep 27, 2010 at 6:23 PM, BB <[email protected]> wrote: > I know this. > Garbage have no to think that this object can be useful for me because > it exits from the scope. > Infact, It destroy the object if it does not cointain event > declaration. > I have to worry because it is not useful but it get memory > full...untill application close! > oEl = nothing is just a verify, but garbage would have to destroy it > also without it if the event is not assigned, OR NOT? > Why it doesnt treat event as the other property?? And overall, is > there a way to free the object that has some event declared? > Maybe the answare is that the event keep an handler of the object that > declare and create it. But when this object is finalized the event and > is handler must be free, or we get a strange situation -.- > > On 27 Set, 16:07, Stephen Russell <[email protected]> wrote: > > On Sat, Sep 25, 2010 at 4:07 AM, BB <[email protected]> wrote: > > > The problem is that I don't attach anything. > > > Try this test code pls, so I will be sure that I am not crazy ^^... > > > > > Public Class CMyClass > > > Inherits Object > > > Private fPropertyOne As String > > > Private fPropertyTwo As Integer > > > Public Event OnSomeEvent(ByRef vSender As Object) > > > End Class > > > > > Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As > > > System.EventArgs) Handles btn1.Click > > > > > Dim i As Integer > > > For i = 0 To 1000 > > > Dim oEl As New CMyClass() > > > Console.WriteLine("element created " & > > > GC.GetTotalMemory(True)) > > > oEl = nothing > > > Console.WriteLine("element after destroying " & > > > GC.GetTotalMemory(True)) > > > Next > > > End Sub > > > End Class > > > > --------------------- > > > > oEI = nothing is just a marker for the garbage collector to use in the > > future. It is not going to be performed on your time and if you call > > it to be performed your performance will get worse. > > > > Think of it as "You are on M$ time" They will decide what is good for > > you and you need not worry about it. > > > > ;-> > > > > -- > > Stephen Russell > > > > Sr. Production Systems Programmer > > CIMSgts > > > > 901.246-0159 cell >
