Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

Possible memory leak in Listgrid on IE

$
0
0
SmartClient: v9.0p_2013-08-19 (2013-08-19)
Browser: IE 9 and 10

In our system, we need to update a ListGrid content every 10 seconds and the system needs to stay open for more and 6 hours without any refresh.

In our tests, what we are seeing is that the browser memory increases continuously until it reaches something like 1GB. At this point the browser freezes and then crashes.

The code below is something similar to what we are doing is our code, but with the difference that it is updating the ListGrid 10 times per second instead of 1 in every 10 seconds.

We ran this code in a Virtual Machine running Windows 7 with 1GB of RAM (with Virtual memory disabled) and IE9.
The results we have are that when the browser uses all the available RAM it simply freezes and the only thing we can do is close it.

Are we doing anything wrong in the code below?

Code:

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-type" content="text/html;charset=UTF-8"/>
    <title>Test</title>
   
    <script>var isomorphicDir = "./isomorphic/";</script>
    <script src="./isomorphic/system/modules/ISC_Core.js"></script>
    <script src="./isomorphic/system/modules/ISC_Foundation.js"></script>
    <script src="./isomorphic/system/modules/ISC_Containers.js"></script>
    <script src="./isomorphic/system/modules/ISC_Grids.js"></script>
    <script src="./isomorphic/system/modules/ISC_Forms.js"></script>
    <script src="./isomorphic/system/modules/ISC_DataBinding.js"></script>
    <script src="./isomorphic/system/modules/ISC_Calendar.js"></script>
    <script src="./isomorphic/skins/Enterprise/load_skin.js"></script>
   
    <script>

    (function(root) {

        var test = root.test = {};

        test.createListGrid = function() {
            isc.ListGrid.create({
                ID: "listGrid",
                width: "100%",
                height: "100%",
                groupByField: "group",
                groupStartOpen: "all",
                dataSource: test.createDataSource(),
                sortField: "itemName",
                sortDirection: "ascending",
                quickDrawAheadRatio: 4.0,
                autoFetchData: false,
                canResizeFields: false,
                canAutoFitFields: false,
                canReorderFields: false,
                virtualScrolling: false,
                showHeaderContextMenu: false,
                groupByAsyncThreshold: 100,
                alternateRecordStyles: true
            });
        };
       
        test.fields = [
            {
                name : "itemName",
                title : "Item",
                type : "text"
            }, {
                name : "unitCost",
                title : "Unit Cost",
                type : "integer"
            }, {
                name : "group",
                title : "Group by",
                type : "text"
            }, {
                name : "button",
                title : "button",
                type : "text"
            }
        ];

        test.createDataSource = function() {
            var dataSource = test.dataSource = isc.DataSource.create({
                ID: "listGridDataSource",
                clientOnly: true,
                fields: test.fields       
            });
           
            return dataSource;
        };
     
        test.init = function() {
           
            test.count = 30;
            test.period = 100;
            test.unitCost = 0;

            test.createListGrid();
           
            listGrid.setData(test.generateData(test.count, test.unitCost));
           
            test.periodicallyUpdate();
        };
       
        test.periodicallyUpdate = function() {
           
            test.unitCost++;
           
            test.updateData();
            setTimeout(test.periodicallyUpdate, test.period);
        };
       
        test.itemName = "itemName";
        test.group = "group";
       
        test.generateData = function(count, unitCost) {
           
            var data = [];
            var item;
           
            for (var i = 0; i < count; i++) {
                item = {
                    itemName: test.itemName + (i < 10 ? "0" : "") + i,
                    unitCost: unitCost,
                    group: test.group + (i % 2),
                    button: "buttonA"
                };
                data[data.length] = item;
            }
           
            return data;
        };
       
        test.updateData = function() {

            var newData = test.generateData(test.count, test.unitCost);
           
            listGrid.invalidateCache();
            listGrid.setData(newData);
        };

    })(this);


    </script>

</head>
<body onload="test.init();">
</body>
</html>


Viewing all articles
Browse latest Browse all 4756

Trending Articles