For long running applications in the browser using a toolkit such as dojo, I hear the point over and over again that dangling references must be avoided. But each language/framework has its own idiosyncrasies when it comes to memory management.
How can I avoid dangling references when building an app in dojo? I’m thinking of rules along the lines of “alloc” in iOS: how to use, and how to clean up after yourself when done.
I think the biggest thing which comes to dojo is that you should remember to disconnect any events you connect.
There’s a simple pattern to this, for example in a custom dijit:
Now, it’s very straightforward to disconnect:
The same pattern applies when using
this.connectin a dijit.