How to properly dispose a BO?


Author
Message
Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Thanks a lot Trent, I really appreciate the time you are taking on this.

Edhy Rijo

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Edhy,

The offending line of code within the StrataFlix sample is this:

    ''' <summary>
    ''' Launches a dialog and adds it to the MDI
    ''' </summary>
    ''' <param name="dialogType"></param>
    ''' <remarks></remarks>
    Private Sub LaunchDialog(ByVal dialogType As System.Type)
        '-- Establish Locals
        Dim f As Form = CType(Activator.CreateInstance(dialogType), Form)

        '-- Add the handlers to the form
        AddFormHandlers(f)

        '-- Set the parent MDI
        f.MdiParent = Me

        '-- Show the dialog
        f.Show()
    End Sub

If you comment out the code that associates the form with the MDI, the form will release.  I tested this a number of different ways including removing any handler, threading close, etc.  If it was attached to an MDI, it stuck around.  Even on a sample dialog outside of StrataFrame, if you do this (and load the dialog as we are here) it is sticking around.  I will play with this some more to see if there is a way to get rid of it.  In ANTS, it indicates that the propertStore is holding onto the disposed reference....which indicates that this is lower level.  I am going to look at .NET through Reflector and see if I can tell what it is doing.

Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Trent,



Those are great news. Thanks!



Beside those changes, I don't think they cover the situation explained here about using MDI forms with the same logic used in StrataFlix. Right now my project is being beta tested and this particular form dealing with a couple of million of records got stock with out of memory error, normally closing the form should fix the problem, but I noticed that a form reference is still hanging when I close the form and the same thing happens on the StrataFlix project.



I have tried many things to fix the problem, but I have not been able to fix it. Could you please take a look at the StrataFlix, using ANT or any other memory profiler and notice that the form reference is left hanging?



At this point I am desperate and open to any suggestion.



Thanks!

Edhy Rijo

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
To All:



We have made some relatively large changes within StrataFrame recently that have not yet been released which will resolve this issue along with other potential memory leaks. Before releasing this build, we are running and testing it to make sure that there are no residual side-effects. It has been running smoothly and effectively in the field for nearly 2 weeks and will be released to the SF community at large next week.



Note: Though many issues will be resolved without any code changes at all, clean development and the release of any handlers or references is required to clean up memory and prevent memory leaks. StrataFrame has been changed to try and clean up things that may not be handled from the developers side to reduce the risk of this happening. However, it is still the developers responsibility to clean up within their code (i.e. if a handler is added make sure it is removed, etc.).
Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Trent,



In this application I am following the same code as in StrataFlix to launch forms and create the _MDIClient objct.



After using ANTS Memory Profiler I noticed that if I open any form, and then close it, a reference of this form will still be hanging. See MovieMaintenance.png picture.



The same is happening with my forms, except that my form is using a large memory chunk and being left hanging it is causing the "out of memory" exception. See MyFormProfiler.png. In some cases the memory used by this form is over 1GB and when I close it and open again, the memory used will just keep increasing.



I have tried several things to get rid of the hanging form without any luck. Could you please take a look at this in the StrataFlix sample and see if you can come up with a way to really close and dispose the MDI child forms?



Thanks!

Edhy Rijo

Attachments
MovieMaintenance.png (212 views, 17.00 KB)
MyFormProfiler.png (210 views, 6.00 KB)
Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Keith,



Thanks for the reference, I downloaded the trial and so far discover that my forms are not being removed from the MDI control in the main/parent form and even when I close any child form, there will be an instance there.



I am reviewing the code to see how to get rid of the form instance that should not be there.

Edhy Rijo

Keith Chisarik
Keith Chisarik
StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)StrataFrame VIP (2.4K reputation)
Group: StrataFrame Users
Posts: 939, Visits: 40K
Should be pretty easy to find with a memory profiler, I use ANTS and they have a free trial.

Keith Chisarik
Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Peter,



Thanks for jump in.



The problem is not importing the records, that is working fine.



The problem is with the lookup BO data which can have 2-4 millions records and when I am done with this data I need to release the memory used by that BO so the process can be done again.



At this point I see the memory used in the task manager and it just keeps going up until it blow out with a not memory error or something like that.

Edhy Rijo

Peter Jones
Peter Jones
Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)Advanced StrataFrame User (718 reputation)
Group: Forum Members
Posts: 386, Visits: 2.1K
Hi Edhy,



I think my approach would be to do this in the database, e.g. import the 360k records into a temp table (I presume they are in an external flat file) and do all the heavy lifting in SQL Server.



Cheers, Peter
Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Greg,



Yeap, I believe the BackgroundWorker may have something to do in here, because the BO is being created and filled in the BackgroundWorker.DoWork() event, which I believe is already in a separate thread as the one when the BackgroundWorker.Completed() is fired.



I am kind of stock now, today's testing has been pretty bad due to this situation which is blowing out with out of memory error.



Hope Trent or anybody else can step in soon here, I am kind of desperate w00t

Edhy Rijo

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search