You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A well known source for memory leaks in SproutCore applications is replacing a SC.RecordArray instance with a new one as content in an array controller without destroying the original instance first. This causes a memory leak because the store will hold on to a reference of the record array instance in order to update it whenever new information is available.
I propose to add the following to SC.ArrayController in order to give a developer warning when someone tries to replace a record array instance which is not destroyed. As SC.ArrayController is in the core_foundation framework, it uses a simple check on properties that need to exists on a record aray instead of using SC.instanceOf(SC.RecordArray).
set: function (key, value) {
if (key === "content") {
var c = this.get('content');
if (c.store || c.query) {
if (!c.get('isDestroyed')) {
SC.warn("Developer Warning: You are replacing the content of an array controller with a new record array without destroying the old one. This causes memory leaks!");
}
}
}
sc_super();
},
Edit: grammar
The text was updated successfully, but these errors were encountered:
It should most certainly go in an //@if debug block. On top of SC.ArrayController there is already one with toString. I intended it to go below (that is where I wrote it). I am just not sure whether this should go to master now, or to 2-0-unstable.
A well known source for memory leaks in SproutCore applications is replacing a SC.RecordArray instance with a new one as content in an array controller without destroying the original instance first. This causes a memory leak because the store will hold on to a reference of the record array instance in order to update it whenever new information is available.
I propose to add the following to SC.ArrayController in order to give a developer warning when someone tries to replace a record array instance which is not destroyed. As SC.ArrayController is in the core_foundation framework, it uses a simple check on properties that need to exists on a record aray instead of using SC.instanceOf(SC.RecordArray).
Edit: grammar
The text was updated successfully, but these errors were encountered: