Ticket #2531080 (closed defect)

Reporter


Chris Klaiber
Opened: 09/9/11
Last modified: 06/12/12
Status: closed
Type: defect
Resolution: duplicate
Duplicate of: #2529690

Owner


Luke Smith
Target Release: 3.6.0
Priority: P3 (normal)
Summary: Memory leak from GUID-based caching in Y.before() and Y.after()
Description:

Y.before() and Y.after() rely on Y._inject() (http://yuilibrary.com/yui/docs/api/files/event-custom_js_event-do.js.html#l117) which caches information using a GUID stamp.

When running YUI in NodeJS and passing in an object to stamp that is unique within each request, data is added to the cache and never removed, and a memory leak results.

If there are other places with YUI where GUID stamp-based caching is used, they may also leak memory in a similar manner.

Type: defect Observed in Version: 3.4.0
Component: Event Severity: S3 (normal)
Assigned To: Luke Smith Target Release: 3.6.0
Location: Library Code Priority: P3 (normal)
Tags: nodejs, searchdirect Relates To:
Browsers: N/A
URL:
Test Information:

Using yui3@0.5.34 and yui3-core@3.4.0 on NodeJS 0.4.5, output is:

{"rss":26628096,"vsize":3125485568,"heapTotal":18382208,"heapUsed":8969544} - initial
{"rss":48410624,"vsize":3133837312,"heapTotal":51860896,"heapUsed":27612624} - after 10000x Y.before()
{"rss":36372480,"vsize":3141439488,"heapTotal":26666400,"heapUsed":24034864} - 10000ms later

Notice how the heapUsed remains high even after the 10 second timeout to allow the GC to run. The sample program:

var YUI = require("yui3").YUI,
iterations = 10000,
timeout = 10000; //millis

function showMem(msg) {
console.warn(JSON.stringify(process.memoryUsage()) + "t - " + msg);
}

YUI().use("event", function(Y) {
showMem("initial");
for (var i = 0; i < iterations; i++) {
var object = {
original: function() { console.warn("original"); }
};

Y.before(function() {
console.warn("before");
}, object, "original");
}

showMem("after " + iterations + "x Y.before()");

//wait for GC to run
setTimeout(function() {
showMem(timeout + "ms later");
}, timeout);
});

Change History

Jenny Donnelly

YUI Developer

Posted: 09/9/11
  • priority changed to P3 (normal)

Dav Glass

Posted: 09/9/11
  • component changed from YUI Global Object to Event
  • owner changed from Dav Glass to Luke Smith
  • status changed from new to assigned

Luke Smith

YUI Contributor

Posted: 09/9/11
  • location changed to Library Code
  • milestone changed to 3.NEXT
  • status changed from assigned to accepted

Setting this to 3.NEXT, but I will try to pull this into 3.5.0. There are other leaks in the event system that I want to address in that release.

Luke Smith

YUI Contributor

Posted: 09/10/11
  • milestone changed from 3.NEXT to 3.5.0

Caridy Patino

YUI Contributor

Posted: 09/11/11
  • keywords changed from nodejs to nodejs, searchdirect

Luke Smith

YUI Contributor

Posted: 11/9/11
  • milestone changed from 3.5.0 to 3.NEXT

Bug scrub. Moving to 3.NEXT with the intention to pull into 3.6.0. 3.5.0 is all DataTable for me, so I can't afford the split bandwidth.

Jenny Donnelly

YUI Developer

Posted: 04/2/12
  • milestone changed from 3.NEXT to 3.6.0

Jenny Donnelly

YUI Developer

Posted: 04/2/12
  • sprint changed to sprint 1

Luke Smith

YUI Contributor

Posted: 04/5/12
  • estimated changed from 0 to 2
  • remaining changed from 0 to 2

Luke Smith

YUI Contributor

Posted: 05/8/12
  • sprint changed from sprint 1 to sprint 2

Luke Smith

YUI Contributor

Posted: 06/12/12
  • sprint changed from sprint 2 to sprint 3

Satyen Desai

YUI Developer

Posted: 06/12/12
  • duplicate changed to 2529690
  • resolution changed to duplicate
  • status changed from accepted to closed

This ticket was marked as a duplicate of #2529690

Satyen Desai

YUI Developer

Posted: 06/12/12

Was fixed in 3.6.0 pr1

Luke Smith

YUI Contributor

Posted: 06/12/12
  • sprint changed from sprint 3 to sprint 1