After profiling my application, I have found that my ASP .NET web application is never freeing up programatically created UltraWebGrids. The ASPX code and the Page_Load's pseudo are below.
Using ANTS Profiler I navigated to the page that has the grid multiple times then forced GC and took a snapshot. I found that all of the programatically created Infragistics controls were still "live".
How do I force the Infragistics controls to be GC'd?
Page_Load Pseduo-code {
grid.Clear();
grid.Columns.Clear();
grid.Rows.Clear();
// programattically create UltraWebGridColumns, UltraGridRows, and UltraGridCells and setting their styles, and other attributes.
}
<asp:Content ID="ContentPlaceHolder_FooTab" runat="server" ContentPlaceHolderID="ContentPlaceHolder_FooTab"> <asp:Panel ID="pnlFooPopup" runat="server" Style="display: none;" CssClass="modalPopup framePopup" Width="300px" Height="300px"> <iframe id="iframeFooPopup" frameborder="0" width="100%" height="100%" src="PopupEmpty.htm"> </iframe> </asp:Panel> <div class="tabContent"> <asp:UpdatePanel ID="upd_Foo" runat="server" EnableViewState="true" RenderMode="Block"> <ContentTemplate> <igtbl:UltraWebGrid ID="grd_Foo" runat="server" Width="100%" OnDeleteRow="grd_Foo_DeleteRow"> <Bands> <igtbl:UltraGridBand> <AddNewRow View="NotSet" Visible="NotSet"> </AddNewRow> </igtbl:UltraGridBand> </Bands> <DisplayLayout AllowColumnMovingDefault="None" AllowDeleteDefault="No" AllowColSizingDefault="Fixed" AllowSortingDefault="No" AllowUpdateDefault="Yes" BorderCollapseDefault="Separate" Name="UltraWebGrid1" RowSelectorsDefault="No" SelectTypeRowDefault="Extended" StationaryMargins="HeaderAndFooter" StationaryMarginsOutlookGroupBy="True" TableLayout="Fixed" Version="4.00" GridLinesDefault="NotSet" RowAlternateStylingDefault="False" ColWidthDefault=""> <FrameStyle BackColor="Window" BorderColor="InactiveCaption" Width="100%" /> <RowStyleDefault Cursor="Default" Font-Strikeout="False" /> <HeaderStyleDefault Wrap="true" /> <AddNewBox Hidden="False"> <BoxStyle BackColor="Window" BorderColor="InactiveCaption" BorderStyle="Solid" BorderWidth="1px"> <BorderDetails ColorLeft="White" ColorTop="White" WidthLeft="1px" WidthTop="1px" /> </BoxStyle> </AddNewBox> <ActivationObject BorderColor="" BorderWidth=""> </ActivationObject> </DisplayLayout> </igtbl:UltraWebGrid> </ContentTemplate> </asp:UpdatePanel> </div></asp:Content>
Hello,
Thanks for writing. I've downloaded and played a bit with RedGate's Ants Profiler (seems like a superb tool), but honestly speaking I have yet to learn to use it (I will follow up with details later).
In any case, garbage collection in ASP.NET works a little bit differently from what you would expect in Winfors/Console application, due to the stateless nature of the request. Each control is re-instantiated after postback and is needed all the way up to the last event of the page (Render), so I am not sure what is the expected behaviour when you try to garbage collect an instance of a control earlier in the cycle, say, in Page_Load.
In any case, I would suggest the following forum thread for additional details:
http://www.velocityreviews.com/forums/t74572-memory-usage-and-garbage-collection.html
There, a lot of Microsoft employees and MVPs are discussing a related topic for GC in ASP.NET, where a customer seems to have the same scenario and tries to garbage collect in Application_EndRequest in Global.asax.
Still, I believe that in ASP.NET typically we need to avoid using GC and threads explicitly and let the runtime do it for us. This seems to be the common conclusion in the thread above as well (although there are interesting details in it).
Thanks for your reply.
To be clear, I am manually GCing from Ants Profiler not the application.
It's not just the current page's infragistics components that are not GC'd, but even previously loaded pages.
--Thanks
My standard grid settings are:
DisplayLayout AllowColSizingDefault:FreeAllowColumnMovingDefault:OnServerAllowSortingDefault:OnClient (You might want to try OnServer)HeaderClickActionDefault:SortSingleLoadOnDemand:XMLRowsRange:50 (How Many Rows The Grid Shows At A Time)SeletTypeCellDefault:SingleSelectTypeRowDefault:SingleSortingAlgorithmDefault:BubbleSortStationaryMargins:HeaderTableLayout:FixedUseFixedHeaders:TrueXMLLoadOnDemand:Virtual
Behavior:Browser:XML
When I used this method, I was able to turn off paging because of the XmlLoadOnDemand. I played around with some of the different options to get to this configuration. Just ran a quick test and using this setup, my dataset I am returning has 11k rows. This loads and shows the first set of rows in around 2-3 seconds. Since I am also working with a large amount of data, I use a filter row to minimize database hits. Hope this helps.
Have you tried setting LoadOnDemand to XML and XMLLoadOnDemandType to Virtual?
I found that this helped quite a bit when working with a ton of data.
Ian
There has not been a follow up, and frankly, in the last year or so I have not heard of complications regarding server-side memory leaks. But then again, we will gladly investigate anything and try to figure out what is going on.
I just want to let you know that sometimes the grid is not responsible for huge memory usage, since it just happens to be the presentation control that is bound to a huge datasource and it is actually the datasource that does most of the damage. So maybe you can use some sort of paging directly in your data retrieving layer (ORM, stored procedure, etc).
But agains - it reallly depends - if you can share some details what happens we will gladly try to provide aditional suggestions.