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
I have a process that will load a couple of million records in BO to do a duplicate record search. My process will import thousands (360K+) of records and then I need to make sure those records does not exist in the database, so instead of querying the data 360k+, I load a BO with all possible duplicate records to check against and this is the million records BO.



Now the problem is that even when I do a BO.Clear to remove those records the application keeps using a lot of memory (over 1gb) and that memory is not released until the whole application is closed, so when the import process starts again, it will blow up with a not enough memory to complete the process.



So what should I do in order to make sure that the memory used once the million record BO is filled is released when using BO.Clear?



Also I am open to suggestions to change my approach if I need to.



Thanks!

Edhy Rijo

Replies
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,



Thanks for jump in here.



This is a bit more complicate because the use of the BO is not in a single method, the BO instance is being created as follow:

Private WithEvents _bizDuplicateCardRecords As New bizTransactionItemsImport




Then, there is a process running in a BackGroundWorker that will call a method, that will call another method and in those methods the _bizDuplicateCardRecords BO is being used.



In the BackgroundWorker.DoWork() I have code like this:



If _bizDuplicateCardRecords IsNot Nothing Then

'-- Make sure the BO is disposed to avoid memory leak from previous use.

_bizDuplicateCardRecords.Dispose()

End If

_bizDuplicateCardRecords = New bizTransactionItemsImport

_bizDuplicateCardRecords.FillPreviousRecordLookup(Me.BizTransaction1.PK_Transaction, Me.BizTransaction1.FK_Vendor_Carrier)







Then in the other methods I use the _bizDuplicateCardRecords, but once a transaction has completed, a new instance is created and filled in the DoWork() event.



But still with all this, if I process 2 transactions the memory just keeps going up. Any other suggestion?

Edhy Rijo

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
I kind of wondered when you asked the question...seemed too easy! Wink



The next thing I'd check into would be events. I.e. I'm wondering if there is a reference to the BO that isn't getting cleaned up related to events. I thought WithEvents was supposed to handle this kind of automagically for you, but...?? The other thing that throws a wrinkle in is threads. If an object is created in one thread, then disposed of in another, is there anything weird about that?



As you can tell my usefulness related to this is rapidly coming to a close...time for the real programmers* to step in... Ermm











* As an aside, check out what a real programmer is...http://www.pbm.com/~lindahl/real.programmers.html
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...




Threaded View
Threaded View
Edhy Rijo - 16 Years Ago
Greg McGuffey - 16 Years Ago
Edhy Rijo - 16 Years Ago
Greg McGuffey - 16 Years Ago
                     Hi Greg,

Yeap, I believe the BackgroundWorker may have...
Edhy Rijo - 16 Years Ago
Peter Jones - 16 Years Ago
Edhy Rijo - 16 Years Ago
Keith Chisarik - 16 Years Ago
Edhy Rijo - 16 Years Ago
Edhy Rijo - 16 Years Ago
                     To All:

We have made some relatively large changes within...
Trent L. Taylor - 16 Years Ago
                         Hi Trent,

Those are great news. Thanks!

Beside...
Edhy Rijo - 16 Years Ago
                             Edhy, The offending line of code within the StrataFlix sample is...
Trent L. Taylor - 16 Years Ago
                                 Thanks a lot Trent, I really appreciate the time you are taking on...
Edhy Rijo - 16 Years Ago
                                 For a further test, I 100% removed StrataFrame from the formula....
Trent L. Taylor - 16 Years Ago
                                     One more thing worth noting. A reference does stick around, but only...
Trent L. Taylor - 16 Years Ago
                                         It does look to be a .NET issue. Once I started looking this up on...
Trent L. Taylor - 16 Years Ago
                                             Hi Trent,

Yes I got the same results in ANTS. During the...
Edhy Rijo - 16 Years Ago
                                                 Here is some information I found on the web about how to overcome the...
Edhy Rijo - 16 Years Ago
                                                 Hi Trent,

Have you have a chance to take a look at this...
Edhy Rijo - 16 Years Ago
                                                     A little. As we had discussed, this is something that we reproduced...
Trent L. Taylor - 16 Years Ago
                                                         Thanks!
Edhy Rijo - 16 Years Ago
                                                             Hi Trent,

Will the new SF release 1.7.0.6 have any effect...
Edhy Rijo - 15 Years Ago
                                                                 Most likely the two are unrelated since the code you are referring to...
Trent L. Taylor - 15 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search