问题描述:

After executing below lines of code, the User object was not being collected by GC. It is was showing on chrome heap snapshot.

Can anyone help?

 define("mockModule", [], function () {

function User(name) {

var that = this;

this.name = name;

this.column = [{ id: 'xyz' }];

this.createObj();

}

User.prototype.createObj = function () {

var that = this;

this.column[0]['formatter'] = outerFunction(that);

};

User.prototype.dummyMethod = function () {

} ;

function outerFunction(that) {

return function () {

return that.dummyMethod(that)

};

}

return { User: User };

});

define("mockModuleImpl", ["mockModule"], function (mockModule) {

function init() {

var user = new mockModule.User("hello");

user = null;

}

return { init: init };

});

require(["mockModuleImpl"], function (mockModuleImpl) {

mockModuleImpl.init();

});

相关阅读:
Top