[CLOSED] Memory leak

Page 3 of 4 FirstFirst 1234 LastLast
  1. #21
    Quote Originally Posted by drkoh View Post
    FYI, i am using 1.6 from the branch. (so the Ext version i think is 3.x? and Ext.JSON is in ext 4.x)

    Sorry, i think i am almost there.. this is what I have

    <head id="Head1" runat="server">    
        <script src="/Resources/js/jquery-1.4.4.min.js" type="text/javascript"></script>
        <script src="/Resources/js/json_sans_eval.js" type="text/javascript"></script>
        <ext:ResourcePlaceHolder ID="ResourcePlaceHolder1" runat="server" Mode="ScriptFiles" />
        <script>
            Ext.JSON.decode = jsonParse;
            Ext.decode = jsonParse;
        </script>
    </head>
    and error in FireBug shows the following:

    TypeError: Ext.JSON is undefined    ==>   Ext.JSON.decode = jsonParse;
    Well, the current thread is within the 2.x Premium Help forum. So, we expected that you use Ext.NET v2.

    For Ext.NET v1 the fix should be:
    <head runat="server">    
        <script src="/Resources/js/json_sans_eval.js" type="text/javascript"></script>
    
        <ext:ResourcePlaceHolder runat="server" Mode="ScriptFiles" />
    
        <script type="text/javascript">  
            Ext.util.JSON.decode = jsonParse; 
            Ext.decode = jsonParse;     
        </script>
    </head>
    Does it help?
  2. #22
    Hi Danill,

    Ya, i tried the
    Ext.util.JSON.decode = jsonParse;
            Ext.decode = jsonParse;
    and I got the following error when ever store reload the data

    Click image for larger version. 

Name:	test.png 
Views:	101 
Size:	23.4 KB 
ID:	5510

    But if I only set
    Ext.util.JSON.decode = jsonParse;
    and remove the
    Ext.decode = jsonParse;
    I dont get the above error.
    Last edited by drkoh; Jan 30, 2013 at 1:07 PM.
  3. #23
    I can't rerpoduce. Here is my test case. Could you provide your one?

    Example
     <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                this.BindData();
            }
        }
    
        protected void MyData_Refresh(object sender, StoreRefreshDataEventArgs e)
        {
            this.BindData();   
        }
    
        private void BindData()
        {
            var store = this.GridPanel1.GetStore();
            
            store.DataSource = this.Data;
            store.DataBind(); 
        }
    
        private object[] Data
        {
            get
            {
                DateTime now = DateTime.Now;
    
                return new object[]
                {
                    new object[] { "3m Co", 71.72, 0.02, 0.03, now },
                    new object[] { "Alcoa Inc", 29.01, 0.42, 1.47, now },
                    new object[] { "Altria Group Inc", 83.81, 0.28, 0.34, now },
                    new object[] { "American Express Company", 52.55, 0.01, 0.02, now },
                    new object[] { "American International Group, Inc.", 64.13, 0.31, 0.49, now },
                    new object[] { "AT&T Inc.", 31.61, -0.48, -1.54, now },
                    new object[] { "Boeing Co.", 75.43, 0.53, 0.71, now },
                    new object[] { "Caterpillar Inc.", 67.27, 0.92, 1.39, now },
                    new object[] { "Citigroup, Inc.", 49.37, 0.02, 0.04, now },
                    new object[] { "E.I. du Pont de Nemours and Company", 40.48, 0.51, 1.28, now },
                    new object[] { "Exxon Mobil Corp", 68.1, -0.43, -0.64, now },
                    new object[] { "General Electric Company", 34.14, -0.08, -0.23, now },
                    new object[] { "General Motors Corporation", 30.27, 1.09, 3.74, now },
                    new object[] { "Hewlett-Packard Co.", 36.53, -0.03, -0.08, now },
                    new object[] { "Honeywell Intl Inc", 38.77, 0.05, 0.13, now },
                    new object[] { "Intel Corporation", 19.88, 0.31, 1.58, now },
                    new object[] { "International Business Machines", 81.41, 0.44, 0.54, now },
                    new object[] { "Johnson & Johnson", 64.72, 0.06, 0.09, now },
                    new object[] { "JP Morgan & Chase & Co", 45.73, 0.07, 0.15, now },
                    new object[] { "McDonald\"s Corporation", 36.76, 0.86, 2.40, now },
                    new object[] { "Merck & Co., Inc.", 40.96, 0.41, 1.01, now },
                    new object[] { "Microsoft Corporation", 25.84, 0.14, 0.54, now },
                    new object[] { "Pfizer Inc", 27.96, 0.4, 1.45, now },
                    new object[] { "The Coca-Cola Company", 45.07, 0.26, 0.58, now },
                    new object[] { "The Home Depot, Inc.", 34.64, 0.35, 1.02, now },
                    new object[] { "The Procter & Gamble Company", 61.91, 0.01, 0.02, now },
                    new object[] { "United Technologies Corporation", 63.26, 0.55, 0.88, now },
                    new object[] { "Verizon Communications", 35.57, 0.39, 1.11, now },
                    new object[] { "Wal-Mart Stores, Inc.", 45.45, 0.73, 1.63, now }
                };
            }
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Simple Array Grid With Paging and Remote Reloading - Ext.NET Examples</title>
    
        <script src="resources/js/jsonParse.js"></script>
     
        <ext:ResourcePlaceHolder runat="server" Mode="ScriptFiles" />
    
        <script>
            Ext.util.JSON.decode = jsonParse;
            Ext.decode = jsonParse;
        </script>
    
        <script type="text/javascript">
            var template = '<span style="color:{0};">{1}</span>';
    
            var change = function (value) {
                return String.format(template, (value > 0) ? "green" : "red", value);
            };
    
            var pctChange = function (value) {
                return String.format(template, (value > 0) ? "green" : "red", value + "%");
            };
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <h1>Array Grid with Paging and Remote Reloading</h1>
            
            <p>Demonstrates how to create a grid from Array data with Local Paging and Remote Reloading.</p>
            
            <p>Notice <b>Last Updated</b> column is revised with a new server-side DateTime stamp when the GridPanel "Refresh" button is clicked.<br />This demonstrates that when the GridPanel is refreshed, the Data is requested again from the server via an DirectEvent, but the Paging and Sorting is done completely client-side in the browser.</p>
    
            <ext:TaskManager ID="TaskManager1" runat="server">
                <Tasks>
                    <ext:Task AutoRun="true" TaskID="servertime" Interval="1000">
                        <Listeners>
                            <Update Handler="GridPanel1.getStore().reload();" />
                        </Listeners>
                    </ext:Task>
                </Tasks>
            </ext:TaskManager>
            
            <ext:GridPanel
                ID="GridPanel1"
                runat="server" 
                StripeRows="true"
                Title="Array Grid" 
                Width="600" 
                Height="290"
                AutoExpandColumn="Company">
                <Store>
                    <ext:Store runat="server" OnRefreshData="MyData_Refresh">
                        <Reader>
                            <ext:ArrayReader>
                                <Fields>
                                    <ext:RecordField Name="company" />
                                    <ext:RecordField Name="price" Type="Float" />
                                    <ext:RecordField Name="change" Type="Float" />
                                    <ext:RecordField Name="pctChange" Type="Float" />
                                    <ext:RecordField Name="lastChange" Type="Date" />
                                </Fields>
                            </ext:ArrayReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:RowNumbererColumn />
                        <ext:Column ColumnID="Company" Header="Company" Width="160" DataIndex="company" />
                        <ext:Column Header="Price" Width="75" DataIndex="price">
                            <Renderer Format="UsMoney" />
                        </ext:Column>
                        <ext:Column Header="Change" Width="75" DataIndex="change">
                            <Renderer Fn="change" />
                        </ext:Column>
                        <ext:Column Header="Change" Width="75" DataIndex="pctChange">
                            <Renderer Fn="pctChange" />
                        </ext:Column>
                        <ext:DateColumn Header="Last Updated" Width="85" DataIndex="lastChange" Format="H:mm:ss" />
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                    <ext:RowSelectionModel runat="server" />
                </SelectionModel>
                <LoadMask ShowMask="true" />
                <BottomBar>
                     <ext:PagingToolbar ID="PagingToolbar1" runat="server" PageSize="10">
                        <Items>
                            <ext:Label runat="server" Text="Page size:" />
                            <ext:ToolbarSpacer runat="server" Width="10" />
                            <ext:ComboBox runat="server" Width="80">
                                <Items>
                                    <ext:ListItem Text="1" />
                                    <ext:ListItem Text="2" />
                                    <ext:ListItem Text="10" />
                                    <ext:ListItem Text="20" />
                                </Items>
                                <SelectedItem Value="10" />
                                <Listeners>
                                    <Select Handler="#{PagingToolbar1}.pageSize = parseInt(this.getValue()); #{PagingToolbar1}.doLoad();" />
                                </Listeners>
                            </ext:ComboBox>
                        </Items>
                    </ext:PagingToolbar>
                </BottomBar>
            </ext:GridPanel>
        </form>
    </body>
    </html>
  4. #24
    Hello @drkoh,

    Any feedback would be appreciated. Does the fix help or not?
  5. #25
    Hi sorry for the late response, I still can't get it to work, below is my sample in MVC

    View Page
    <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>OMS View</title>
        <link href="/Resources/css/ui.css" rel="stylesheet" type="text/css" />
        <script src="../../Resources/js/jquery-1.4.4.min.js" type="text/javascript"></script>
        <script type="text/javascript" src="/Resources/js/site.js"></script>
        <script src="/Resources/js/json_sans_eval.js" type="text/javascript"></script>
        <ext:ResourcePlaceHolder ID="ResourcePlaceHolder1" runat="server" Mode="ScriptFiles" />
        <script>
            Ext.util.JSON.decode = jsonParse;
            Ext.decode = jsonParse;
        </script>
    </head>
    <body>
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <div id="StoreGroup">
            <ext:Store ID="Store_Test" runat="server" ShowWarningOnFailure="true" WarningOnDirty="false" AutoLoad="false" RemoteSort="true">
                <Proxy>
                    <ext:HttpProxy Url="/OMSRead/GetTest/" />
                </Proxy>
                <Reader>
                    <ext:JsonReader IDProperty="TestId" Root="data" TotalProperty="total">
                        <Fields>
                            <ext:RecordField Name="Test" Type="String" />
                        </Fields>
                    </ext:JsonReader>
                </Reader>
                <BaseParams>
                    <ext:Parameter Name="start" Value="0" Mode="Raw" />
                </BaseParams>
            </ext:Store>
        </div>
        <div id="ContentGroup" style="">
            <ext:Viewport ID="Viewport1" runat="server" Layout="BorderLayout">
                <Items>
                    <ext:Panel ID="Panel2" runat="server" Layout="BorderLayout" Region="Center" Border="false" Cls="border-bottom">
                        <Items>
                            <ext:GridPanel ID="GridPanel_Test" Region="Center" StripeRows="true" runat="server" StoreID="Store_Test" Border="false" TrackMouseOver="true" Cls="border-right">
                                <ColumnModel ID="ColumnModel1" runat="server">
                                    <Columns>
                                        <ext:Column DataIndex="Test" Header="Test" Width="100" Hideable="false">
                                        </ext:Column>
                                    </Columns>
                                </ColumnModel>
                                <SelectionModel>
                                    <ext:RowSelectionModel ID="RowSelectionModel1" runat="server">
                                    </ext:RowSelectionModel>
                                </SelectionModel>
                                <BottomBar>
                                    <ext:PagingToolbar ID="PagingToolbar1" runat="server" PageSize="50">
                                        <Items>
                                        </Items>
                                    </ext:PagingToolbar>
                                </BottomBar>
                            </ext:GridPanel>
                        </Items>
                    </ext:Panel>
                </Items>
            </ext:Viewport>
        </div>
    </body>
    </html>
    Controller
    public AjaxStoreResult GetTest() {
                AjaxStoreResult result = new AjaxStoreResult("");
                try
                {
                    int total = 1;
                    string[] d = { "Test" };
                    var list = from i in d
                               select new
                               {
                                   TestId = 1,
                                   Test = "Test"
                               };
                    result = new AjaxStoreResult(list, total);
                }
                catch (Exception ex) { }
                return result;
            }
    And below is the error I got when Load data
    Click image for larger version. 

Name:	Untitled.png 
Views:	105 
Size:	8.4 KB 
ID:	5549
    Last edited by drkoh; Feb 05, 2013 at 1:37 PM.
  6. #26
    Thank you for the sample.

    The error occurs because of this JSON parser can't work with unquoted properties names. AjaxStoreResult doesn't quote "data" and "total".

    We switched it to be quoted in Ext.NET v2, but will leave as it in Ext.NET v1 as it is.

    I can suggest to use a JsonResult.

    Example
    public ActionResult GetTest()
    {
        return new JsonResult()
        {
            Data = new
            {
                data = new
                {
                    TestId = "tesdID",
                    Test = "test"
                },
                Total = 1
            }
        };
    }
  7. #27
    HI Daniil,

    If I have a collection of data, how would I manually generate the string for the data member?

    thanks.
  8. #28
    Please try this (pseudo code):

    public ActionResult GetTest()
    {
        return new JsonResult()
        {
            Data = new
            {
                data = JSON.Serialize("a collection of data"),
                Total = "a collection of data".Count
            }
        };
    }
  9. #29
    Hi, i tried the following and these are the result

    public ActionResult GetTest()        {
                return new JsonResult()
                {
                    Data = new
                    {
                        //Doesn't Works
                        //data = JSON.Serialize(new[] { new { Test = "aaa", TestId = "1" }, new { Test = "bbb", TestId = "2" } }),
                        
                        //Works:
                        //data = new[] { new { Test = "aaa", TestId = "1" }, new { Test = "bbb", TestId = "2" }} ,
                        Total = 2
                    }
                };
            }
    Doesn't work If using JSON.Serialize i got
    {"data":"[{\"Test\":\"aaa\",\"TestId\":\"1\"},{\"Test\":\"bb b\",\"TestId\":\"2\"}]","Total":2}
    and works if using the manual way i got
    {"data":[{"Test":"aaa","TestId":"1"},{"Test":"bbb","TestId" :"2"}],"Total":2}

    Thanks.
  10. #30
    I was wrong, a JSON.Serialize call is not required. JsonResult serializes itself.
Page 3 of 4 FirstFirst 1234 LastLast

Similar Threads

  1. [CLOSED] [1.0] Performance in IE6 (memory leak?)
    By danielg in forum 1.x Legacy Premium Help
    Replies: 9
    Last Post: Apr 27, 2012, 2:57 PM
  2. Memory Leak with Grid Local Filter
    By reverseblade in forum 1.x Help
    Replies: 1
    Last Post: Apr 27, 2011, 10:00 AM
  3. Memory leak desktop application
    By Yannis in forum 1.x Help
    Replies: 0
    Last Post: Apr 05, 2011, 3:47 AM
  4. TaskManager cause IE memory leak
    By Tom Zhang in forum 1.x Help
    Replies: 1
    Last Post: Sep 19, 2010, 5:32 AM
  5. Memory Leak in I.E.
    By crazypsdev in forum 1.x Help
    Replies: 6
    Last Post: Nov 09, 2009, 9:55 AM

Tags for this Thread

Posting Permissions