执行下面的代码行后,GC没有收集User
个对象。它正在镀铬堆快照上显示。
有人可以帮忙吗?
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();
});