Open
Description
I'm investigating a memory leak in qBittorrent, and it appears that MooTools is the culprit.
The issue is in clean
, which stores item.uniqueNumber
in uid
, then calls item.removeEvents
, then checks if uid != null
to decide whether to clean up the item's storage.
The problem is that item.removeEvents
can call item.retrieve('events')
which always calls Slick.uidOf
and get
, which assign item.uniqueNumber
and allocate it storage respectively.
The memory leak can be resolved by either preventing retrieve
from allocating storage (since read operations shouldn't affect state):
retrieve: function(property, dflt){
- var storage = get(Slick.uidOf(this)), prop = storage[property];
+ if (!this.uniqueNumber || !storage[this.uniqueNumber]) return;
+ var storage = storage[this.uniqueNumber], prop = storage[property];
if (dflt != null && prop == null) prop = storage[property] = dflt;
return prop != null ? prop : null;
},
or by taking item.uniqueNumber
in clean
after calling item.removeEvents
:
var clean = function(item){
- var uid = item.uniqueNumber;
if (item.removeEvents) item.removeEvents();
if (item.clearAttributes) item.clearAttributes();
+ var uid = item.uniqueNumber;
if (uid != null){
delete collected[uid];
delete storage[uid];
}
return item;
};
I'm happy to create a PR for this.
Metadata
Metadata
Assignees
Labels
No labels