Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple Dojo Widget Leak Detection
// Query the registry
my_widgets = [];
dijit.registry.forEach(function(widget){
my_widgets.push(widget.id);
});
console.log("Widgets Captured (" + dijit.registry.length + ") in total)");
// Query it again, produce a Diff
var leakyWidgets = [];
dijit.registry.forEach(function(widget){
if(dojo.indexOf(my_widgets, widget.id) === -1) {
leakyWidgets.push(widget.declaredClass);
}
});
console.log(leakyWidgets.length + " potential leaks found");
console.log("Potential Leaks: " + leakyWidgets.join(", "));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment