How to solve the OutOfMemoryException

  1. #1

    How to solve the OutOfMemoryException

    Hi,

    I have a procedure that returns 150,000 rows. OutOfMemoryException error occurs.

    How to solve this?

    The figure below explains:

    Click image for larger version. 

Name:	OutOfMemoryException 150000 registros.jpg 
Views:	124 
Size:	71.4 KB 
ID:	2030

    Thanks.
  2. #2
  3. #3
    Danill,

    The example that was posted is doing a select on the bench. In my case I have a list that already returns 150 000 rows.

    How could I treat this list?

    Sorry, I am a layman and I need an example with database, they do not understand the lambda ...

    Explain better please?


    Thanks!
    Last edited by Dig2010; Dec 13, 2010 at 6:23 PM.
  4. #4
    Hi,

    When you are binding your data to the Store, please bind no more than 100 records.
    Geoffrey McGill
    Founder
  5. #5
    Hi,

    Sorry, but this is what I do not know control. My list comes with 150,000. The store procedure that returns all those records.
  6. #6
    Quote Originally Posted by Dig2010 View Post
    Hi,

    Sorry, but this is what I do not know control. My list comes with 150,000. The store procedure that returns all those records.
    For general ASP.NET and/or SQL questions, it would be best to ask in the ASP.NET Forums (http://forums.asp.net).
    Geoffrey McGill
    Founder
  7. #7
    geoffrey,

    The PageIndex property of the asp: GridView does this. The component does not ExtJs?
  8. #8
    Hi Geoffrey/Daniil,

    To solve the problem of paging, I modified my stored procedure by placing the following parameters:

    stp_paging( @PageStart     INT,    @PageLimit     INT,    @TotalCount    INT OUTPUT)
    ...
    And I have the C # method BindData () that calls this stored procedure.
    Method:

            private void BindData()
            {
                var store = this.grdDetalheCritica.GetStore();
    
                try
                {
                    ExtracaoCriticaBusiness objExtracaoCriticaBss = new ExtracaoCriticaBusiness();
                    List<ExtracaoCriticaDomain> lstExtracaoCritica = objExtracaoCriticaBss.Paging(PageStart, PageLimit, TotalCount );
    
                    if (lstExtracaoCritica == null)
                    {
                        X.MessageBox.Alert("Aviso", "Não existem dados!").Show();
                    }
                    else
                    {
                        store.DataSource = lstExtracaoCritica;
                        store.DataBind();
                        Session.Remove(Util.Constantes.strSessProdutoID);
                    }
                }
                catch (Exception ex)
                {
                    X.MessageBox.Alert("Aviso", ex.Message).Show();
                }
            }
    How will I manage the paging on ext:GridPanel? Could you explain?

    Thanks!
  9. #9
    Quote Originally Posted by Dig2010 View Post
    How will I manage the paging on ext:GridPanel? Could you explain?
    The samples/demos for paging and sorting should give a fairly good idea of what's going on
    https://examples1.ext.net/#/GridPane...rting/Handler/

    hth /Peter
  10. #10
    Galley

    I did like the example below...
    https://examples1.ext.net/#/GridPane...rting/Handler/

    But the previous page passes parameters. How do I use these parameters with the. ashx?

    Perhaps to be easier to understand seeing the codes:

    ASPX:
    <body>
        <form id="frmLoteMovDetalheCritica" runat="server">
            <ext:resourcemanager id="Resourcemanager1" runat="server" directmethodnamespace="LoteMovDetalhesCriticas" />
            
            <asp:HiddenField ID="lote_Id_Item" runat="server" />
            <asp:HiddenField ID="status_Id_Item" runat="server" />
            <asp:HiddenField ID="sigla_Item" runat="server" />
            
            <ext:window id="winLoteMovDetalheCriticas" 
                        runat="server" 
                        closable="false" 
                        resizable="false" 
                        icon="ApplicationViewList"
                        title="Detalhes das Críticas" 
                        width="1100px" 
                        minheight="406" 
                        maxheight="690" 
                        draggable="false" 
                        padding="5" 
                        layout="Form">
                <Items>
                    <ext:Panel ID="pnlDetalhe" runat="server">
                        <Content>
                            <div style="height:auto">
                                <table cellspacing="0" cellpadding="3" rules="rows" border="1" id="ctl00_ContentPlaceHolder1_GridViewDestinatario"
                                    style="width: 1074px; border-collapse: collapse;">
                                    <tr style="color: #F7F7F7; background-color: #6B696B; font-weight: bold; height:125;">
                                        <th scope="col">
                                            &nbsp;
                                        </th>
                                        <th scope="col">
                                            Data Início
                                        </th>
                                        <th scope="col">
                                            Data Fim
                                        </th>
                                        <th scope="col">
                                            Nome
                                        </th>
                                        <th scope="col">
                                            Status
                                        </th>
                                    </tr>
                                    <tr style="color: #4A3C8C; background-color: white;">
                                        <td align="center" style="width: 56px;">
                                            &nbsp;
                                        </td>
                                        <td>
                                            <asp:Label ID="lblDtInicio" runat="server" Text=""></asp:Label>
                                        </td>
                                        <td>
                                            <asp:Label ID="lblDtFim" runat="server" Text=""></asp:Label>
                                        </td>
                                        <td>
                                            <asp:Label ID="lblDescLote" runat="server" Text=""></asp:Label>
                                        </td>
                                        <td>
                                            <asp:Label ID="lblStatusLote" runat="server" Text=""></asp:Label>
                                        </td>
                                    </tr>
                                </table>
                                
                                <table runat="server" cellspacing="0" id="tbGridViewLoteMovimentacaoDetalhes" align="center" width="1074px">
                                    <tr align="center" style="height: 25px" valign="middle">
                                        <th class="Titulo2">
                                            <asp:Label ID="lblTituloGrid_LoteMovimentacaoDetalhes" runat="server"></asp:Label>
                                        </th>
                                    </tr>
                                </table>
                                
                                <ext:GridPanel ID="grdDetalheCritica" runat="server" Layout="Center" StripeRows="true" Width="1074px" Height="309"
                                    MaxHeight="358" AutoExpandColumn="EXT_NFNro" AutoScroll="True" Y="50" X="50">
    
                                    <Store>
                                        <ext:Store ID="Store1" runat="server" RemoteSort="true">
                                            <Proxy>
                                                <ext:HttpProxy Method="GET" Url="LoteMovDetalheCriticaHandler.ashx" />
                                            </Proxy>
                                            <AutoLoadParams>
                                                <ext:Parameter Name="start" Value="={0}" />
                                                <ext:Parameter Name="limit" Value="={5}" />
                                                <ext:Parameter Name="lote" Value="=#{lote_Id_Item}.Value" />
                                                <ext:Parameter Name="status" Value="=#{status_Id_Item}.Value" />
                                                <ext:Parameter Name="sigla" Value="=#{sigla_Item}.Value" />
                                            </AutoLoadParams>
                                            <Reader>
                                                <ext:JsonReader Root="Data" TotalProperty="TotalRecords">
                                                    <Fields>
                                                        <ext:RecordField Name="EXT_Id" />
                                                        <ext:RecordField Name="EXT_LMV_ID" />
                                                        <ext:RecordField Name="EXT_CriId" />
                                                        <ext:RecordField Name="EXT_NFNro" />
                                                        <ext:RecordField Name="EXT_NFSerie" />
                                                        <ext:RecordField Name="EXT_ItemDescr" />
                                                        <ext:RecordField Name="EXT_DtEmissao" />
                                                        <ext:RecordField Name="EXT_EmitenteCNPJ" />
                                                        <ext:RecordField Name="Status_Atual_ID" />
                                                    </Fields>
                                                </ext:JsonReader>
                                            </Reader>
                                            <SortInfo Field="EXT_NFNro" Direction="ASC" />
                                        </ext:Store>
                                    </Store>
                                    
                                    <ColumnModel ID="ColumnModel1" runat="server">
                                        <Columns>
                                            <ext:Column Width="5px" ColumnID="EXT_Id" Header="ID da Extração" DataIndex="EXT_Id" Hidden="true">
                                            </ext:Column>
                                            <ext:Column Width="5px" ColumnID="EXT_CriId" Header="ID do Descarte" DataIndex="EXT_CriId" Hidden="true">
                                            </ext:Column>
                                            <ext:Column Width="70px" ColumnID="EXT_LMV_ID" Header="ID do Lote" DataIndex="EXT_LMV_ID" Align="Left">
                                            </ext:Column>
                                            <ext:Column Width="65px" ColumnID="EXT_NFNro" Header="Nota Fiscal" DataIndex="EXT_NFNro" Align="Center">
                                                <Renderer Fn="linkNFRenderer" />
                                            </ext:Column>
                                            <ext:Column Width="50px" ColumnID="EXT_NFSerie" Header="Série" DataIndex="EXT_NFSerie" Align="Center">
                                            </ext:Column>
                                            <ext:Column Width="500px" ColumnID="EXT_ItemDescr" Header="Produto" DataIndex="EXT_ItemDescr" Align="Left">
                                            </ext:Column>
                                            <ext:DateColumn Format="dd/MM/yyyy" Width="70px" ColumnID="EXT_DtEmissao" Header="Emissão" DataIndex="EXT_DtEmissao" Align="Center">
                                            </ext:DateColumn>
                                            <ext:Column Width="130px" ColumnID="EXT_EmitenteCNPJ" Header="Emitente" DataIndex="EXT_EmitenteCNPJ" Align="Left">
                                            </ext:Column>
                                            <ext:ImageCommandColumn Width="167px" ColumnID="btnTodos" Header="Ação" Align="Left">
                                                <Commands>
                                                    <ext:ImageCommand CommandName="EM_BRANCO" />
                                                    <ext:ImageCommand CommandName="DESCARTAR" IconCls="cursor-delete">
                                                        <ToolTip Text="Descartar Registro" />
                                                    </ext:ImageCommand>
                                                </Commands>
                                                <PrepareCommand Fn="prepareCommand" />
                                            </ext:ImageCommandColumn>
                                        </Columns>
                                    </ColumnModel>
                                    
                                    <SelectionModel>
                                        <ext:RowSelectionModel ID="RowSelModelLoteMov" runat="server" />
                                    </SelectionModel>
                                    
                                    <LoadMask ShowMask="true" />
                                    
                                    <BottomBar>
                                        <ext:PagingToolbar ID="PagingToolbar1" runat="server" PageSize="100" DisplayMsg="Registros {0} - {1} de {2}">
                                            <Items>
                                                <ext:ToolbarSpacer ID="ToolbarSpacer2" runat="server" Width="30" />
                                                <ext:Label ID="Label1" runat="server" Text="Qtde Registro por Página:" />
                                                <ext:ToolbarSpacer ID="ToolbarSpacer1" runat="server" Width="10" />
                                                <ext:ComboBox ID="ComboBox1" runat="server" Width="50">
                                                    <Template Visible="False" ID="ctl195" EnableViewState="False">
                                                    </Template>
                                                    <Items>
                                                        <ext:ListItem Text="20" />
                                                        <ext:ListItem Text="40" />
                                                        <ext:ListItem Text="60" />
                                                        <ext:ListItem Text="80" />
                                                        <ext:ListItem Text="100" />
                                                    </Items>
                                                    <SelectedItem Value="100" />
                                                    <Listeners>
                                                        <Select Handler="#{PagingToolbar1}.pageSize = parseInt(this.getValue()); #{PagingToolbar1}.doLoad();" />
                                                    </Listeners>
                                                </ext:ComboBox>
                                            </Items>
                                        </ext:PagingToolbar>
                                    </BottomBar>
                                    <View>
                                        <ext:BufferView ID="BufferView1" runat="server" RowHeight="34" ScrollDelay="0" />
                                    </View>
                                </ext:GridPanel>
                            </div>
                        </Content>
                    </ext:Panel>
                </Items>
            </ext:window>
        </form>
    </body>
    C#
    using System;
    
    namespace Saraiva.Margem.Application
    {
        public partial class LoteMovDetalheCritica : System.Web.UI.Page
        {
            private Int32 lm_id = 0;
            private Int32 intStatus = 0;
            private String strSigla = String.Empty;
            private String strDescStatus = String.Empty;
    
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!Page.IsPostBack)
                {
                    lblDtInicio.Text = Session["DtInicio"].ToString();
                    lblDtFim.Text = Session["DtFim"].ToString();
                    lblDescLote.Text = Server.HtmlDecode(Session["DescLote"].ToString());
                    lblStatusLote.Text = Server.HtmlDecode(Session["StatusLote"].ToString());
                    lblTituloGrid_LoteMovimentacaoDetalhes.Text = Request.QueryString["LMR_DescStatus"];
    
                    lm_id = Convert.ToInt32(Request.QueryString["LMR_LMV_Id"]);
                    intStatus = Convert.ToInt32(Request.QueryString["LMR_Status"]);
                    strSigla = Request.QueryString["LMR_Sigla"];
                    strDescStatus = Request.QueryString["LMR_DescStatus"];
    
                    this.lote_Id_Item.Value = Request.QueryString["LMR_LMV_Id"];
                    this.status_Id_Item.Value = Request.QueryString["LMR_Status"];
                    this.sigla_Item.Value = Request.QueryString["LMR_Sigla"];
                }
            }
        }
    }
    .ashx
    using System.Web;
    using Ext.Net;
    using System.Web.Services;
    
    namespace Saraiva.Margem.Application
    {
        /// <summary>
        /// Summary description for $codebehindclassname$
        /// </summary>
        [WebService(Namespace = "http://tempuri.org/")]
        [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
        public class LoteMovDetalheCriticaHandler : IHttpHandler
        {
    
            public void ProcessRequest(HttpContext context)
            {
                context.Response.ContentType = "application/json";
    
                var start = 0;
                var limit = 10;
                var sort = string.Empty;
                var dir = string.Empty;
                var query = string.Empty;
                var lote = 0;
                var status = 0;
                var sigla = string.Empty;
    
                if (!string.IsNullOrEmpty(context.Request["lote"]))
                {
                    lote = int.Parse(context.Request["lote"]);
                }
    
                if (!string.IsNullOrEmpty(context.Request["status"]))
                {
                    status = int.Parse(context.Request["status"]);
                }
    
                if (!string.IsNullOrEmpty(context.Request["sigla"]))
                {
                    sigla = context.Request["sigla"];
                }
    
                if (!string.IsNullOrEmpty(context.Request["start"]))
                {
                    start = int.Parse(context.Request["start"]);
                }
    
                if (!string.IsNullOrEmpty(context.Request["limit"]))
                {
                    limit = int.Parse(context.Request["limit"]);
                }
    
                if (!string.IsNullOrEmpty(context.Request["sort"]))
                {
                    sort = context.Request["sort"];
                }
    
                if (!string.IsNullOrEmpty(context.Request["dir"]))
                {
                    dir = context.Request["dir"];
                }
    
                Paging<ExtracaoCriticaDomain> lstLotMovDetCritica = ExtracaoCriticaDomain.LotMovCriDetPaging(start, limit, sort, dir, query, lote, status, sigla);
    
                context.Response.Write(JSON.Serialize(lstLotMovDetCritica));
            }
    
            public bool IsReusable
            {
                get
                {
                    return false;
                }
            }
        }
    }
    Using. ashx, I have problems with Session and Request.QueryString

    Could someone help me urgently, I am trying to do this control to three days.

    Thank you for your attention and help!

Similar Threads

  1. Replies: 3
    Last Post: Nov 30, 2010, 11:07 AM
  2. Replies: 0
    Last Post: Nov 17, 2010, 8:39 AM
  3. [CLOSED] Help to solve strange issue
    By turione in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 08, 2010, 7:24 AM
  4. [SOLVE] Problem with subwindow layout
    By acrossdev in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jun 29, 2009, 6:37 AM
  5. Replies: 5
    Last Post: Mar 23, 2009, 7:43 PM

Posting Permissions