YUILibrary - Open source JavaScript and CSS for building richly interactive software.
Fork YUI on GitHub

YUI 2.x

Ticket #2512149 (accepted defect)

Reporter


sfbugs
Opened: 01/16/09
Last modified: 07/15/09
Status: accepted
Type: defect

Owner


Dav Glass
Target Release: FUTURE
Priority: P3 (normal)
Summary: Memory leaked by Editor destroy method
Description:

Each time an Editor (or SimpleEditor) instance is created and then destroyed, memory is leaked.

Take the following snippet which repeatedly creates and then destroys a Panel instance. No memory is leaked.

var x;
setInterval(function(){
if (x) {
x.destroy();
x = null;
}
else {
var node = document.createElement('div');
document.body.appendChild(node);

x = new YAHOO.widget.Panel(node, {
height: '300px',
width: '522px'
});
x.render();
}
}, 2000);

Now try the same thing with Editor:

var x;
var node;
setInterval(function(){
if (x) {
x.destroy();
x = null;

// manually remove node because SimpleEditor's destory() method
// doesn't do it for us (unlike Panel)
YAHOO.util.Event.purgeElement(node, true);
document.body.removeChild(node);
}
else {
node = document.createElement('div');
document.body.appendChild(node);

x = new YAHOO.widget.SimpleEditor(node, {
height: '300px',
width: '522px'
});
x.render();
}
}, 2000);

I'm seeing ~1.5Mb per create/destroy cycle in FFx 3.0.5 (Ubuntu), Opera 9.62 (Ubuntu) and Chrome 1.0.154.36 (WinXP) and predictably, about an order of magnitude worse on IE7 (WinXP).

Under Ubuntu browser memory usage is easily observed via the top command. Under WinXP the task manager was used (iexplore.exe memory) and under Chrome the built-in Task Manager makes the phenomenon
even more apparent (per-tab memory usage).

A html file is attached that reproduces the bug.

Regards,

Patrick Donelan
http://patspam.com

Type: defect Observed in Version: 2.7.0
Component: Editor Severity: S3 (normal)
Assigned To: Dav Glass Target Release: FUTURE
Location: Library Code Priority: P3 (normal)
Tags: Relates To:
Browsers: N/A
URL:
Test Information:

Attachments

Attachment #1: 309341_leak.htm (download)

Change History

sfbugs

Posted: 01/21/09

This ticket was imported from Source Forge.

Orginially submitted by: patspam

George

YUI Developer

Posted: 02/4/09
  • browser changed to
  • location changed to
  • owner changed to Dav Glass
  • priority changed from P4 (low) to P3 (normal)
  • testinfomation changed to

Rick Walsh

Posted: 04/22/09
  • browser changed to N/A
  • type changed from Bugs to defect

Similiar to bug #2527865 - Where I've commented and started work on here: http://github.com/keepoffthegrass/yui2/tree/master

The bug is http://yuilibrary.com/projects/yui2/ticket/2527865#properties

Dav Glass

YUI Developer

Posted: 04/23/09
  • location changed to Library Code
  • milestone changed to 2.NEXT
  • resolution changed from None
  • status changed from assigned to accepted
  • version changed from 2.6.0 to 2.7.0

Dav Glass

YUI Developer

Posted: 06/26/09
  • milestone changed from 2.NEXT to 2.8.0

Dav Glass

YUI Developer

Posted: 07/15/09
  • milestone changed from 2.8.0 to FUTURE

Setting to FUTURE, but I am implementing things as I find them.

Dav Glass

YUI Developer

Posted: 07/15/09

ref #2512149 - Addes some memory management to Editor Buttons
View Commit: 6654e0811f63f2b8ab5def070646cc5e6e73efad