Tuesday, 15 February 2011

firefox - Javascript memory leak(?) -



firefox - Javascript memory leak(?) -

for reason next function works fine in chrome/ie seams cause memoryleak in firefox.

function draw(x, y, width, height, color) { fillstyle = bctx.createlineargradient(x-width/2, y-height/2, x+width/2, y+height/2); if (color == 1) { fillstyle.addcolorstop(0, 'rgb(142,214,255)'); fillstyle.addcolorstop(1,'rgb(0,76,179)'); } else if (color == 2) { fillstyle.addcolorstop(0,'rgb(255,142,214)'); fillstyle.addcolorstop(1,'rgb(179,0,76)'); } bctx.fillstyle = fillstyle; bctx.fillrect(x-width/2, y-height/2, width, height); }

i imagine it's because you're referencing global variable fillstyle. alter to:

var fillstyle = bctx.createlineargradient(x-width/2, y-height/2, x+width/2, y+height/2);

javascript firefox memory-leaks

No comments:

Post a Comment