I've encountered a strange problem - application is rapidly slowing down as it runs. Only thing that springs to mind is a memory leak, but how to detect it in javascript? Are there any tools? Anyway, here's the code:
function draw_ship(){
//Body
var sbpaint = ctx.createLinearGradient(shipx+20,shipy,shipx+20,shipy+15);//painting the ship
sbpaint.addColorStop(0,'rgb(220,220,230)');
sbpaint.addColorStop(1,'rgb(150,150,160)');
ctx.fillStyle = sbpaint;
ctx.moveTo(shipx,shipy);
ctx.lineTo(shipx+40,shipy);
ctx.lineTo(shipx+55,shipy+15);
ctx.lineTo(shipx-15,shipy+15);
ctx.fill();
//Head
var shpaint = ctx.createLinearGradient(shipx+20,shipy,shipx+20,shipy-20);
shpaint.addColorStop(0,'rgb(200,200,210)');
shpaint.addColorStop(1,'rgb(100,100,110)');
ctx.fillStyle = shpaint;
ctx.arc(shipx+20,shipy,20,Math.PI,Math.PI*2,false);
ctx.fill();
}
As you see, it is very straightforward, and I'm really puzzled, where the leak could be. Application itself is here: link, choose 'Scroller' from menu.
Thank you for your time.