Backbone Marionette - Layout View Zombies
<p>I am having an issue in my Backbone Marionette application where my child views are not being destroyed completely.  How do you properly destroy a nested layout view that you are replacing with another layout/item view?</p>

<p>I was under the impression from the <a href="http://marionettejs.com/docs/v2.4.4/marionette.layoutview.html#destroying-a-layoutview" rel="nofollow">Marionette documentation on destroying layout views</a>, that when I set a region to display a new view, that the old view is destroyed.  However, events that are triggered via <em>vent</em> are still visible by the old view that was supposedly destroyed.</p>

<p>I created a sample of this issue here: <a href="https://jsfiddle.net/dhardin/5j3x2unx/" rel="nofollow">https://jsfiddle.net/dhardin/5j3x2unx/</a></p>

<p>I believe the issue stems from my router:</p>

<pre><code>App.Router = Marionette.AppRouter.extend({
  routes: {
    '': 'showView1',
    'view1': 'showView1',
    'view2': 'showView2'

  },
  showView1: function() {
    var view1 = new App.View1();
    App.Layout.mainRegion.empty();
    App.Layout.mainRegion.show(view1);
  },
  showView2: function() {
    var view2 = new App.View2();
    App.Layout.mainRegion.empty();
    App.Layout.mainRegion.show(view2);
  }
});
</code></pre>

<p>The <strong>App.Layout.mainRegion.empty()</strong> is not required to my understanding as that is taken care of when the view is destroyed in the <em>Region Manager's</em> <strong>show()</strong> function. 
To see the issue, navigate to another view via navigation, and click the button.  You will see that the alert is fired for both the old view and the new view.</p>

<p>Back in my pre-marionette applications, I followed a clean-up pattern to avoid these memory leaks discussed <a href="https://lostechies.com/derickbailey/2011/09/15/zombies-run-managing-page-transitions-in-backbone-apps/" rel="nofollow">here</a>.  </p>

<p>Essentially, my displayed view would call the following function when my app changes to a new view:</p>

<pre><code>Backbone.View.prototype.close = function(){
  this.remove();
  this.unbind();
}
</code></pre>

<p>Please let me know if you need any additional info.  Thanks in advance!</p>