PDA

View Full Version : [FIXED] Memory Leak in Sencha Touch



mschwartz
29 Jul 2011, 5:07 AM
The following simple HTML+JavaScript example crashes on our iPad within 15 minutes:





<!doctype html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>ZingChart Sencha Touch Demo</title>

<link rel="stylesheet" href="../sencha-touch-1.0.1a/resources/css/sencha-touch.css" type="text/css">

<script type="text/javascript" src="../sencha-touch-1.0.1a/sencha-touch-debug.js"></script>

<script type="text/javascript" >

Ext.setup({

onReady: function () {



var charts = 50;



for (var i=0;i<charts;i++) {

document.body.innerHTML += '<div id="panel' + i + '" style="float:left;margin:10px;"></div>';

}



var aCharts = [], c = 0;

var types = ['decline', 'confirm'];



function paintCharts() {

for (var i=0;i<charts;i++) {

if (aCharts[i]) {

aCharts[i].destroy();

}

}

aCharts = [];

c = 0;

for (var i=0;i<charts;i++) {

var panel = new Ext.Panel({

html: 'HTML ' + parseInt(9999*Math.random(), 10),

renderTo: 'panel' + i,

width: 200,

height: 100,

items: [

{

items: [

new Ext.Button({

ui : types[parseInt(types.length*Math.random(), 10)],

text: 'Button ' + parseInt(9999*Math.random(), 10)

})

]

}

]

});

aCharts.push(panel);

}

setTimeout(paintCharts, 1000);

}



window.setTimeout(paintCharts, 1000);



}

});



</script>

</head>

<body>



</body>

</html>

mschwartz
29 Jul 2011, 5:08 AM
The following HTML+JavaScript crashes on our iPad within 10 minutes:





<!doctype html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>ZingChart Sencha Touch Demo</title>

<link rel="stylesheet" href="../sencha-touch-1.0.1a/resources/css/sencha-touch.css" type="text/css">

<script type="text/javascript" src="../sencha-touch-1.0.1a/sencha-touch-debug.js"></script>

<script type="text/javascript" >

Ext.setup({

onReady: function () {



var charts = 50;



for (var i=0;i<charts;i++) {

document.body.innerHTML += '<div id="panel' + i + '" style="float:left;margin:10px;"></div>';

}



var aCharts = [], c = 0;

var types = ['decline', 'confirm'];



function paintCharts() {

for (var i=0;i<charts;i++) {

if (aCharts[i]) {

aCharts[i].destroy();

}

}

aCharts = [];

c = 0;

for (var i=0;i<charts;i++) {

var panel = new Ext.Panel({

html: 'HTML ' + parseInt(9999*Math.random(), 10),

renderTo: 'panel' + i,

width: 200,

height: 100,

items: [

{

items: [

new Ext.Button({

ui : types[parseInt(types.length*Math.random(), 10)],

text: 'Button ' + parseInt(9999*Math.random(), 10)

})

]

}

]

});

aCharts.push(panel);

}

}



window.setInterval(paintCharts, 1000);



}

});



</script>

</head>

<body>



</body>

</html>

mschwartz
29 Jul 2011, 5:09 AM
The following HTML+JavaScript ran for more than 8 hours without crashing:




<!DOCTYPE html>
<html>
<head>
<title>ZingChart HTML5 Beta</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-language" content="en">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
</head>

<body>

<script type="text/javascript">

var cnt = 0;
var charts = 1000;
var timeout = 100;

var zingchart = {
render : function(p) {
// nothing
zingchart.complete();
},
exec : function() {
// nothing
}
}

var c = 0;

function render() {
for (var i=0;i<charts;i++) {
zingchart.render();
}
}

function destroy() {
for (var i=0;i<charts;i++) {
zingchart.exec();
}
}

function test() {
c = 0;
destroy();
render();
}

zingchart.complete = function() {
c++;
if (c == charts) {
cnt++;
document.getElementById('cnt').innerHTML = cnt;
//console.error('End');
window.setTimeout(test, timeout);
}
}

window.onload = test;

</script>

<div id="cnt"></div>

</body>
</html>

mitchellsimoens
29 Jul 2011, 5:27 AM
Hmmm Thank you for the effort into testing for 8 hours on that one test :) Have you tried the tests with Sencha Touch 1.1.0? I see you are using 1.0.1a.

Either way I am letting internal know of this.

mschwartz
29 Jul 2011, 5:35 AM
Hmmm Thank you for the effort into testing for 8 hours on that one test :) Have you tried the tests with Sencha Touch 1.1.0? I see you are using 1.0.1a.

Either way I am letting internal know of this.

Other than using a newer version of Touch (which we will), do you see anything that should cause a leak?

mitchellsimoens
29 Jul 2011, 5:38 AM
Other than using a newer version of Touch (which we will), do you see anything that should cause a leak?

No... the destroy should take care of the Panels with Buttons so everything should be good.

mschwartz
1 Aug 2011, 5:06 AM
This is turning into a really big deal for one of our clients. They wrote the Sencha Touch program, and are a well known and large company.

mitchellsimoens
1 Aug 2011, 8:33 AM
Pretty colors :)

Got it running on my iPad...

mitchellsimoens
1 Aug 2011, 9:13 AM
Still running after almost 50 min using the first code that crashed your iPad after 15 min. If ST isn't the problem, the let's compare iOS version? I'm on 4.3.4

mitchellsimoens
1 Aug 2011, 9:29 AM
Almost on the dot, an hour later mobile Safari crashed

mschwartz
1 Aug 2011, 11:14 AM
Yeah, your iPad probably has more memory or less apps running ;-)

mitchellsimoens
1 Aug 2011, 11:16 AM
As you have noticed I have gona ahead and opened a ticket since it wasn't getting a whole lot of attention.

mschwartz
1 Aug 2011, 11:30 AM
You found a bug! We've classified it as TOUCH-315. We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.

mschwartz
2 Aug 2011, 10:01 AM
Any word on this?

Any kind of override or whatever would really help. The client is going code complete on their Sencha Touch app and will be submitting it to their QA dept. at the end of this week.

Thanks.