Now I am doing this. I noticed a couple of things: 1) look at any use of $ (window) .fn () - where fn is any of the functions on the window object; if you do this more than once, you add several event handlers to the global object, which causes a memory leak
2) $ rootScope. $ watch () - similarly, if you do this more than once (say, when loading the directive), you add several handlers to the global object
3) In my tests (where I go back and forth between two pages) it seems that chrome consumes a lot of memory (in my case, almost 1 GB) before garbage collection starts. Maybe when you hit the “garbage” collection “chrome doesn't actually make a GC? Or is it a GC for javacsript but not for dom elements?
4) If you add an event handler to the dom element and then remove it from dom, the handlers will never get GC'ed.
source share