Skip to content

Instantly share code, notes, and snippets.

@danielericlee
Created October 4, 2011 23:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielericlee/1263127 to your computer and use it in GitHub Desktop.
Save danielericlee/1263127 to your computer and use it in GitHub Desktop.
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