Memory leak in Rolodex?

Memory leak in Rolodex?

Old forum URL: forums.lhotka.net/forums/t/6532.aspx


James Thomas posted on Friday, February 27, 2009

Hi All,

I think I've run into a memory problem in rolodex, but am not sure how to fix it. I have an app based on Rolodex (with more pages and much more data) and noticed that memory increased each time I changed pages. Checking back, I've found that Rolodex does the same.

This line: this.LayoutRoot.Children.Remove(this.LayoutRoot.Children[0]); doesn't seem to be freeing the memory used by the last page. I've added an explicit call to GC, but the memory keeps increasing.

Has anyone else come across this and found the solution?

Thanks, James.

James Thomas replied on Saturday, February 28, 2009

Just to add to this, memory used by IE is:

Loading login screen: 23mb
Logging on: 31mb
Editing AT&T: 35mb
Closing edit on AT&T: 36mb
Editing AT&T: 38mb
Closing edit on AT&T: 39mb
etc...

Randomly clicking edit and close on the screens results in more and more memory being taken, but not released.

Does anyone else see this, or is it something connected with my setup? My application loads more data than rolodex, so quickly runs up 300+mb..

skagen00 replied on Saturday, February 28, 2009

James,

I've finished my first CSLA w/ Silverlight proof-of-concept for an internal application (very happy with the result) and am preparing to move onto my second one that has some business applicability. I haven't had the chance to test mine for a memory leak, but I am watching this thread very closely myself - it's an interest to me too.

If I get a chance to test mine out for memory leaks, I'll post the results here. In the meantime, I'm interested in this subject too.

Chris

James Thomas replied on Sunday, March 01, 2009

After a bit more investigation, I'm wondering if the problem is the ValidatedDataGridTextColumns I'm using in the datagrid on a particular page. I use 14 of these columns in the grid and am testing on 25 rows of data (in reality, we'll have a lot more). The datatype of all the cells is decimal. Performance is sluggish for all actions on the page and after repeated loads becomes unacceptably slow.

When comparing the validated columns with standard text columns, there's this difference in memory consumption of IE after one load of the page:
75,340mb  after page load with ValidatedDataGridTextColumn
56,912mb after page load using standard DataGridTextColumn

After refreshing the data 10 times, there's this difference:
107,440mb with ValidatedDataGridTextColumn
65,888mb using standard DataGridTextColumn

I don't know if this is actually a memory leak, or whether it's just how ValidatedDataGridTextColumns need to work, but even though I'm not asking much of them at the moment, I don't think they are usable in my application - which is a real shame, because they offer far better functionality.

There's this thread (http://forums.lhotka.net/forums/thread/26314.aspx) on the subject of the ValidatedDataGridTextColumns from a while ago. Has anyone else had similar problems, or found a solution?

Thanks, James.

sergeyb replied on Sunday, March 01, 2009

Did you try by any chance just creating a templated column with PropertyStatus?  This is essentially what ValidatedDataColumn is.  I would be curious what performance would be in comparison with Validated column…

 

Sergey Barskiy

Principal Consultant

office: 678.405.0687 | mobile: 404.388.1899

cid:_2_0648EA840648E85C001BBCB886257279
Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

 

From: James Thomas [mailto:cslanet@lhotka.net]
Sent: Sunday, March 01, 2009 6:59 PM
To: Sergey Barskiy
Subject: Re: [CSLA .NET] Memory leak in Rolodex?

 

After a bit more investigation, I'm wondering if the problem is the ValidatedDataGridTextColumns I'm using in the datagrid on a particular page. I use 14 of these columns in the grid and am testing on 25 rows of data (in reality, we'll have a lot more). The datatype of all the cells is decimal. Performance is sluggish for all actions on the page and after repeated loads becomes unacceptably slow.

When comparing the validated columns with standard text columns, there's this difference in memory consumption of IE after one load of the page:
75,340mb  after page with ValidatedDataGridTextColumn
56,912mb after page using standard DataGridTextColumn

After refreshing the data 10 times, there's this difference:
107,440mb with ValidatedDataGridTextColumn
65,888mb using standard DataGridTextColumn

I don't know if this is actually a memory leak, or whether it's just how ValidatedDataGridTextColumns need to work, but even though I'm not asking much of them at the moment, I don't think they are usable in my application - which is a real shame, because they offer far better functionality.

There's this thread (http://forums.lhotka.net/forums/thread/26314.aspx) on the subject of the ValidatedDataGridTextColumns from a while ago. Has anyone else had similar problems, or found a solution?

Thanks, James.


James Thomas replied on Monday, March 02, 2009

I've just tried it. Nothing fancy - just a textbox with the csla propertystatus. Performance goes sluggish in the same way as with the validated columns. I had to put things back quickly though, as I'm deploying this app for testing now, so didn't have time for a detailed investigation. Can something later if it would help. What kind of scenario would be a good test?

Thanks, James.

sergeyb replied on Monday, March 02, 2009

I think just a large number of rows and columns would be OK. Property status does have some overhead, but should not be much.

 

Sergey Barskiy

Principal Consultant

office: 678.405.0687 | mobile: 404.388.1899

cid:_2_0648EA840648E85C001BBCB886257279
Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

 

From: James Thomas [mailto:cslanet@lhotka.net]
Sent: Monday, March 02, 2009 5:59 AM
To: Sergey Barskiy
Subject: Re: [CSLA .NET] RE: Memory leak in Rolodex?

 

I've just tried it. Nothing fancy - just a textbox with the csla propertystatus. Performance goes sluggish in the same way as with the validated columns. I had to put things back quickly though, as I'm deploying this app for testing now, so didn't have time for a detailed investigation. Can something later if it would help. What kind of scenario would be a good test?

Thanks, James.


ajj3085 replied on Monday, March 02, 2009

Well, I have to ask.. are you sure there's a memory leak?  GC.Collect isn't an order, it's suggestion to the GC.  Depending on how you're determine the memory usage, and what you're application is doing, there might not be any problem at all.  Increasing memory usage does not even necessarily mean a memory leak.

So.. what problems are leading to suspect a memory leak?  OOM Exception?  Sluggishness?  Something else?  Did you run ANTS profiler?  What about FxCop?  The latter will help you find Disposable objects which aren't being disposed.. those seem to be the only time memory actually is leaking.

Jack replied on Tuesday, March 10, 2009

Did you get any further with your investigation... Here is a link that might help:

http://blogs.msdn.com/delay/archive/2009/03/09/controls-are-like-diapers-you-don-t-want-a-leaky-one-implementing-the-weakevent-pattern-on-silverlight-with-the-weakeventlistener-class.aspx

James Thomas replied on Monday, March 16, 2009

Jack:
Did you get any further with your investigation... Here is a link that might help:

http://blogs.msdn.com/delay/archive/2009/03/09/controls-are-like-diapers-you-don-t-want-a-leaky-one-implementing-the-weakevent-pattern-on-silverlight-with-the-weakeventlistener-class.aspx


Thanks for the link, Jack, it got me thinking and experimenting. I wondered whether the eventhandlers on page.xaml.cs were behaving in the way that page described, but after removing them (and just reloading the page time and again) I'm getting the same behaviour. I can't see what the problem is... Will keep testing and post again if I find anything.

James Thomas replied on Tuesday, March 17, 2009

Quick update: I think the sluggish behaviour of grids with ValidatedDataColumns is a separate issue. Things are certainly sluggish, but I get the same memory problems with standard text columns (without the app appearing sluggish to begin with), so am concentrating on the memory issues at the moment.

James Thomas replied on Monday, March 16, 2009

ajj3085:
Well, I have to ask.. are you sure there's a memory leak?  GC.Collect isn't an order, it's suggestion to the GC.  Depending on how you're determine the memory usage, and what you're application is doing, there might not be any problem at all.  Increasing memory usage does not even necessarily mean a memory leak.

So.. what problems are leading to suspect a memory leak?  OOM Exception?  Sluggishness?  Something else?  Did you run ANTS profiler?  What about FxCop?  The latter will help you find Disposable objects which aren't being disposed.. those seem to be the only time memory actually is leaking.


Yes - OOM exception - if I reload the page enough times I get memory usage in IE up to 1.47GB and then VS throws the exception. I don't know where the problem is though (see below).

Copyright (c) Marimer LLC