I have a quiz application built in backboneJS, I have three views. A QuizView which shows the overall progress and back/next buttons. A PageView that contains a group of questions and a QuestionView for each question.
When a user goes to the next page in a quiz I remove the current PageView by calling a destroy function that calls Backbone's remove() on the page itself and all the questions. (all listeners are attached with listenTo)
It's my expectation that after I do this that DOM nodes should not longer be reflected in memory timeline. I've attached a view of the DOM node count from Chrome dev tools and you can see it goes up as you go to new pages.
I also took a heap snapshot and when I look at the detached DOM items they all have one item (the div container for a page) that has a single item in the retaining tree. I'm assuming this is why they are not being collected.
Can anyone provide insight at to why the DOM node count continuously goes up?
Also this is my destroy function in PageView:
destroy: function(){
console.log("PageView :: destroy " + this)
_.each(this.childViews, function(view){
view.remove();
});
this.remove();
}