Memory leak SF BO with DevExpress ASPxDataGridView


Author
Message
ChanKK
ChanKK
Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)
Group: Forum Members
Posts: 190, Visits: 1.3K
Hi,

I am facing memory leak problem when using SF BusinessObject and DevExpress ASPxDataGridView.

I have simple test project, which only has one BO, bind to ASPxDataGridView. It does nothing complicated, just load all records in Page_Load if not IsPostBack.



I found that, the memory usage would become double when I just "refresh" the page. I also used dotTrace profiler and found that # of BO instances keep increasing. I suspect it is the same issue with the post http://forum.strataframe.net/Topic20903-8-1.aspx.



I have prepared sample project and the dotTrace memory profiler files for your reference. MemoryLeak1.dtm is first load memory snapshot and MemoryLeak2.dtm is 2nd snapshot after refresh.



As the file size > 30MB, please download it from http://www.visualsolutions.com.my/blog/chankk/WebApplication6.zip



Hope you could get back to me as soon as possible! It is very urgent!



Thank you
Replies
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
Just FYI, your sample is missing the BusinessobjectLibrary6 project.  So we are having to recreate this on our own.  If you can provide that project as part of your sample it may speed things up.
ChanKK
ChanKK
Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)
Group: Forum Members
Posts: 190, Visits: 1.3K
Hi,

I have attached the missing project.

Beside, I spent some time to trace the root cause of this issue and found that, BusinessBindingSource.Dispose() is not called at all. Do you think it is the cause?



Thank you
Attachments
Properties.zip (361 views, 7.00 KB)
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
Sorry that this has taken so long, but in this instance, there is no memory leak and nothing wrong within the SF code or WBBS class.

We do not have DevExpress 8.2 downloaded and tested this using version 8.1.1.0.  When bringing in all 20,000 records, which is unrealistic, it was very slow but there was not a memory leak.  DevExpress is re-evaluating all rows with each navigation forward.

We reduced the query to the top 200 records for a control to look for any type of memory leak, and we actually noticed the memory being cleaned up and getting smaller.  As expected, the memory grew the first few page navigations, but after about the 5th navigation, the memory consumption reduced and began to keep a more level memory base.

I believe that your issue is one of two things:

  1. A possible issue with the DevExpress 8.2 grid not cleaning up after itself.
  2. Your application is loading too much data and not cleaning up BOs which could cause a memory bloat before there is ever a chance to clean up.

Finally, the WBBS is entirely different than the WinForms BBS.  The Web BBS does not create a unique BO instance for each row.  There is only ever a single BO instance ever used or created.  So the same issue that existed within the WinForms version is not possible on the web.  After looking over the code, we cannot even see where a potential memory leak may occur.

Hope this helps give some direction.  Thanks.

ChanKK
ChanKK
Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)
Group: Forum Members
Posts: 190, Visits: 1.3K
Hi,

Shall you please test using DevExpress 8.2?

I will ask DevEx team to test as well. However, it might takes another day for response which I am not afford to wait anymore.



Thank you for help.
ChanKK
ChanKK
Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)
Group: Forum Members
Posts: 190, Visits: 1.3K
Trent L. Taylor (03/18/2009)



Finally, the WBBS is entirely different than the WinForms BBS. The Web BBS does not create a unique BO instance for each row. There is only ever a single BO instance ever used or created. So the same issue that existed within the WinForms version is not possible on the web. After looking over the code, we cannot even see where a potential memory leak may occur.





Hi,

I used to debug my web app, and found that the code below is called for every row populated by ASPxGridView. If referring to the code below, it create new instance BO for each call and stored it into _BusinessObjectList. Therefore, I feel a bit curious about what you mentioned as above. Please advice. Thank you



Private Function CreateShareAndAddBusinessObject(ByVal index As Integer) As BusinessLayer

'-- Create a new object

Dim loReturn As BusinessLayer = CType(Activator.CreateInstance(Me._BusinessObject.GetType()), BusinessLayer)



'-- Share the table

Me._BusinessObject.ShareCurrentDataTable(loReturn)



'-- Set the parent business object of the instance object

loReturn.ParentBusinessObject = _BusinessObject.ParentBusinessObject



'-- Add the object to the list

Me._BusinessObjectList.Add(index, loReturn)



'-- Return the new object

Return loReturn

End Function


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
That particular method doesn't play into this. However, we have made a change to the enumerator which could have a potential leak in this scenario.  We created a situation with an enumerator that would force a leak and with the change, it resolved the issue.  So I think that this will resolve your problem altogether.  I will send you a PM with the link for the download.
ChanKK
ChanKK
Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)
Group: Forum Members
Posts: 190, Visits: 1.3K
Hi,

I have tested with the fix you sent, but when refresh the page, it hit error as below, which didn't happen before this fix.



System.NullReferenceException was unhandled by user code

Message="Object reference not set to an instance of an object."

Source="MicroFour StrataFrame Business"

StackTrace:

at MicroFour.StrataFrame.Business.BusinessBindingSource.BusinessObject_CurrentDataTableRefilled()

at MicroFour.StrataFrame.Business.BusinessLayer.raise_CurrentDataTableRefilled()

at MicroFour.StrataFrame.Business.BusinessLayer.OnCurrentDataTableRefilled()

at MicroFour.StrataFrame.Business.BusinessLayer.ChangeCurrentDataTable(DataTable NewTable, Boolean AcceptChanges, Boolean IsSharedTable)

at MicroFour.StrataFrame.Business.BusinessLayer.FillDataTable(String SelectStatement)

at WebApplication8._Default.Page_Load(Object sender, EventArgs e) in C:\Documents and Settings\KKCHAN\My Documents\Visual Studio 2008\Projects\WebApplication8\Default.aspx.cs:line 20

at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)

at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)

at System.Web.UI.Control.OnLoad(EventArgs e)

at System.Web.UI.Control.LoadRecursive()

at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

InnerException:





Shall you please test using the attachment I posted in previous post and DevExpress 8.2 to ensure the issue could be fixed? It has taken too long time for this, and also because of our timezone, we might not response immediately cause some unnecessary delay.



Thank you
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
Sorry, this exception was easily reproducable and we already have a fix.  I will send you a PM with a link to download the Business assembly.  This is the only thing that changed.
ChanKK
ChanKK
Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)
Group: Forum Members
Posts: 190, Visits: 1.3K
Hi,

I tested it and it fixed the problem. I will release it to our QC for further testing, will update you if any news. Thank you for your help on this. You safe my life!



Thank you
ChanKK
ChanKK
Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)
Group: Forum Members
Posts: 190, Visits: 1.3K
Hi,

After some more testing, I still found "memory leak". When I doing data entry/refresh/Callback the page (few times), the memory will be increasing and reach about 100-120MB. Then, it will drop about 80-90MB and increasing again. And we can see that, for every "drop", that is about 20-30MB is not clearly cleaned. Once it run for certain period (about 40 records entered), w3wp.exe will eat up 700MB (based on machine) and OutOfMemoryException occurred.



I use dottrace to snapshot memory and found that are at least 300MB garbage object in memory, System.String[], DataTime[], Datetime, DataRow, RBTree.Node[], String and etc.



May I know what cause this problem? Is it caused by DataBinding or...? How could I prevent this?



I have attached the screenshot. Please advice. Urgent!
Attachments
garbage.JPG (287 views, 112.00 KB)
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
Chan,

The screen shot you provided doesn't do me any good.  We have taken the sample that you have provided and NOT had the same results.  You already know that if we are to help you we are going to need some form of reproduction otherwise there is nothing we can do for you.  Please provide a sample that reproduces the issue.  I would strongly suggest that you make sure that you have the most recent build and assemblies loaded that I sent to you the other day.  I never posted the source online, so if you recompiled the source, then you are not running the most recent build.

This has happened to you in the past where you accidentally had the wrong version of the assemblies in your environment.  Using the most recent StrataFrame assemblies, we are not experiencing this using a WBBS and a grid.  However, I will not say that the possibility of what you are experiencing doesn't exist...but without a sample that we can reproduce on our side, there is very little I can do in this type of circumstance.

ChanKK
ChanKK
Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)
Group: Forum Members
Posts: 190, Visits: 1.3K
Hi,

OK, I will prepare sample for it.



However, I would like to double clarify with you, the MicroFour StrataFrame Business.dll shipped with latest Setup (fix thread safe issue) is version 1.6.6.9 and file size 781KB? Because the hot fix that you sent me last time (fix memory leak) is 1.6.6.8 with file size 801KB. I was thinking you 1.6.6.8 might contains debug info therefore is larger.



Does 1.6.6.9 include the memory leak fix as well?



Please advice.



Thank you
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
Does 1.6.6.9 include the memory leak fix as well?

Yes.  As for the file size, I am unsure why it was smaller other than I might have sent you just that one file in debug mode.  But your assessment is correct.

ChanKK
ChanKK
Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)Advanced StrataFrame User (622 reputation)
Group: Forum Members
Posts: 190, Visits: 1.3K
Hi,

I have created sample project, which is exactly the same as previous one. It only contains 1 BO and DevExpress GridView. I keep reload the page and below is the log of memory taken by each drop



First Load - 52564

First Memory Drop - 55316

Second Memory Drop - 56260

Third Memory Drop - 56284

Fourth Memory Drop - 56400

Fiveth Memory Drop - 57268

and etc



I recorded video. Please download it from



http://www.visualsolutions.com.my/blog/chankk/memory.zip



I also recorded using performance monitor which as attached. During performance monitoring, I found that, the memory will keep increasing, drop, stay at same level for a while, then will increase again for some time (this jump will be almost back to previous before drop level and more), then drop again (but is higher that previous drop), stay for a while and increase again.



The sample project is very simple, therefore the memory leak is not that serious. If I run my web app, it easily eat up few hundred MB.



Sample Project: http://www.visualsolutions.com.my/blog/chankk/WebApplication12.zip



Please advice. Thank you
Attachments
.NET Memory_000001.zip (272 views, 28.00 KB)
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
ChanKK - 16 Years Ago
Trent L. Taylor - 16 Years Ago
ChanKK - 16 Years Ago
Trent L. Taylor - 16 Years Ago
ChanKK - 16 Years Ago
Trent L. Taylor - 16 Years Ago
                         Hi,
May I know any update? Do you think it could be solved in...
ChanKK - 16 Years Ago
                             We are looking at this right now and trying to reproduce. Should know...
Trent L. Taylor - 16 Years Ago
                                 Just FYI, your sample is missing the BusinessobjectLibrary6 project....
Trent L. Taylor - 16 Years Ago
                                     Hi,
I have attached the missing project.
Beside, I spent...
ChanKK - 16 Years Ago
                                     Sorry that this has taken so long, but in this instance, there is no...
Trent L. Taylor - 16 Years Ago
                                         Hi,
Shall you please test using DevExpress 8.2?
I will ask...
ChanKK - 16 Years Ago
                                         [quote][b]Trent L. Taylor (03/18/2009)[/b]

Finally, the...
ChanKK - 16 Years Ago
                                             That particular method doesn't play into this. However, we have made a...
Trent L. Taylor - 16 Years Ago
                                                 Hi,
I have tested with the fix you sent, but when refresh the...
ChanKK - 16 Years Ago
                                                     Sorry, this exception was easily reproducable and we already have a...
Trent L. Taylor - 16 Years Ago
                                                         Hi,
I tested it and it fixed the problem. I will release it to...
ChanKK - 16 Years Ago
                                         Hi,
After some more testing, I still found "memory leak". When I...
ChanKK - 16 Years Ago
                                             Chan, The screen shot you provided doesn't do me any good. We have...
Trent L. Taylor - 16 Years Ago
                                                 Hi,
OK, I will prepare sample for it.

However, I would...
ChanKK - 16 Years Ago
                                                     [quote]Does 1.6.6.9 include the memory leak fix as well?[/quote] Yes....
Trent L. Taylor - 16 Years Ago
                                                         Hi,
I have created sample project, which is exactly the same as...
ChanKK - 16 Years Ago
ChanKK - 16 Years Ago
Trent L. Taylor - 16 Years Ago
ChanKK - 16 Years Ago
ChanKK - 16 Years Ago
ChanKK - 16 Years Ago
                         Chan, We have looked at this from a number of angles. I am at a loss...
Trent L. Taylor - 16 Years Ago
                             Hi,
I hope you do not misunderstand me, I do appreciate SF help...
ChanKK - 16 Years Ago
                             Hi,
[quote]Some of your issues are coming from retrieving vast...
ChanKK - 16 Years Ago
                                 Chan, I appreciate your comments. We too appreciate you and your...
Trent L. Taylor - 16 Years Ago
                                     Hi,
Any status?

Beside, as promised I have downloaded...
ChanKK - 16 Years Ago
                                         Hi,
BTW, the error posted just now happen to all page that...
ChanKK - 16 Years Ago
                                             Sorry, one more week past. Any update?

Thank you
ChanKK - 16 Years Ago
                                                 Chan, We have not reproduced your memory leak as we had mentioned in...
Trent L. Taylor - 16 Years Ago
                                                     Hi,
As mentioned in PM, the actual problem of Save transaction is...
ChanKK - 16 Years Ago
                                                         Hi,
After further thinking, don't feel loCommand =...
ChanKK - 16 Years Ago
                                                             Agreed. The Clone should not cause an issue as it creates a unique...
Trent L. Taylor - 16 Years Ago
                                                                 Hi,
Any hint how to troubleshoot on this?

Thank you
ChanKK - 16 Years Ago
                                                                     Well, this thread is getting a bit ambiguous. I was just commenting on...
Trent L. Taylor - 16 Years Ago
                                     Hi,
After some further testing, I think I found the root cause of...
ChanKK - 16 Years Ago
                                         Glad you found a solution. We will take this post into consideration...
Trent L. Taylor - 16 Years Ago
ChanKK - 15 Years Ago
Trent L. Taylor - 15 Years Ago
Trent L. Taylor - 15 Years Ago
Trent L. Taylor - 15 Years Ago
ChanKK - 15 Years Ago
Trent L. Taylor - 15 Years Ago
ChanKK - 15 Years Ago
ChanKK - 15 Years Ago
Ivan George Borges - 15 Years Ago
ChanKK - 15 Years Ago
Ivan George Borges - 15 Years Ago
                         Hi Could you reproduce the memory leak issue? I need solution ASAP....
ChanKK - 15 Years Ago
                             Sorry Chan, not yet.
Ivan George Borges - 15 Years Ago
ChanKK - 15 Years Ago
ChanKK - 15 Years Ago
Ivan George Borges - 15 Years Ago
ChanKK - 15 Years Ago
Ivan George Borges - 15 Years Ago
                         [quote][b]Ivan George Borges (10/29/2010)[/b][hr]Hi Chan. Well,...
ChanKK - 15 Years Ago
                             Thanks for posting, Chan. I will reproduce here just in case we loose...
Ivan George Borges - 15 Years Ago
ChanKK - 15 Years Ago
Ivan George Borges - 15 Years Ago
ChanKK - 15 Years Ago
             Not yet, Chan.
Ivan George Borges - 15 Years Ago
ChanKK - 15 Years Ago
ChanKK - 15 Years Ago
Ivan George Borges - 15 Years Ago
ChanKK - 15 Years Ago
Ivan George Borges - 15 Years Ago
     any updates??
ChanKK - 15 Years Ago
             No Chan, not yet.
Ivan George Borges - 15 Years Ago
ChanKK - 15 Years Ago
Ivan George Borges - 15 Years Ago
Trent L. Taylor - 14 Years Ago
ChanKK - 14 Years Ago
Trent L. Taylor - 14 Years Ago
ChanKK - 14 Years Ago
ChanKK - 14 Years Ago
Trent L. Taylor - 14 Years Ago
ChanKK - 14 Years Ago
ChanKK - 14 Years Ago
ChanKK - 14 Years Ago
Trent L. Taylor - 14 Years Ago
ChanKK - 14 Years Ago
ChanKK - 14 Years Ago
Trent L. Taylor - 14 Years Ago
ChanKK - 14 Years Ago
Trent L. Taylor - 14 Years Ago
ChanKK - 14 Years Ago
Trent L. Taylor - 14 Years Ago
Peter Jones - 14 Years Ago
ChanKK - 14 Years Ago
ChanKK - 14 Years Ago
ChanKK - 14 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search