I'm currently diving into Backbone.js, and working on a few complex web apps. I've done a fair amount of research on view (and nested view) management, and making sure that all events are unbound when a view is left or destroyed. I'm currently using ThoughtBot's solution to this - Backbone Support (using composite views and swapping routers).
Even though I'm not encountering any tell-tale problems regarding the above, is there any way to make sure or test that views are getting properly cleaned up? I would love be to be able to make sure that I'm going about things properly!
Thanks!
You could use the memory profiler in Chrome's dev tools. Set up a test that creates 1000 Views, destroys them, and then repeats over and over.
The profiler should show gradual increases in memory punctuated by steep declines when garbage collection runs. If things are getting cleaned up properly, your overall average memory usage over a sufficiently long duration should be consistent.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With