Opened 10 years ago

Closed 10 years ago

#9424 closed defect (fixed)

dojo.delegate() can leak the last object

Reported by: Eugene Lazutkin Owned by: Eugene Lazutkin
Priority: lowest Milestone: 1.4
Component: Core Version: 1.3.0
Keywords: Cc:
Blocked By: Blocking:

Description

dojo.delegate() retains a reference to the last used object thus pseudo-leaking it.

It can be fixed like that (in dojo/_base/lang.js):

dojo.delegate = dojo._delegate = (function(){
  // boodman/crockford delegation w/ cornford optimization
  function TMP(){}
  return function(obj, props){
    TMP.prototype = obj;
    var tmp = new TMP();
    if(props){
      dojo._mixin(tmp, props);
    }
    // THE NEXT LINE CLEARS THE REFERENCE
    TMP.prototype = null;
    return tmp; // Object
  }
})();

Change History (2)

comment:1 Changed 10 years ago by Eugene Lazutkin

Component: GeneralCore
Milestone: tbd1.4
Owner: changed from anonymous to Eugene Lazutkin
Status: newassigned

comment:2 Changed 10 years ago by Eugene Lazutkin

Resolution: fixed
Status: assignedclosed

(In [18621]) dojo.delegate: removing a leak, !strict, fixes #9424.

Note: See TracTickets for help on using tickets.