Okei, I Think I solved. Thank for all your answares. They were useful. Garbage's delay in destroying objects I think is not the problem because, as I explaned, memory gets immediatly free if you cancel "event" declaration. So the difference is only in "event" keyword declaration that (I suppose) creates some handlers that you don't control also if the event is never assigned. Changing declaration using directly delegates in place of events leaves the object free to be really finalized.
Thanks a lot! EM On 29 Set, 09:20, Raghupathi Kamuni <[email protected]> wrote: > public static long GetTotalMemory( > bool forceFullCollection > )http://msdn.microsoft.com/en-us/library/system.gc.gettotalmemory.aspx > If the forceFullCollection parameter is true, this method waits a short > interval before returning while the system collects garbage and finalizes > objects. The duration of the interval is an internally specified limit > determined by the number of garbage collection cycles completed and the > change in the amount of memory recovered between cycles. The garbage > collector does not guarantee that all inaccessible memory is collected. > > > > On Tue, Sep 28, 2010 at 9:05 AM, May0rDav3 <[email protected]> wrote: > > Would there be a performance increase if the class implements the > > idisposable interface and calls the dispose method (and then remove it > > from the queue for the garbage man so he doesn't have to stop)? > >http://msdn.microsoft.com/en-us/library/system.idisposable(v=VS.80).aspx > > > On Sep 27, 10:07 am, 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
