Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
40
Programmatic UltraWebGrid Memory Leak
posted

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>

Parents
  • 28464
    posted

    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).


Reply Children