title: setTimeout memory leak in Titanium Appcelerator
body: <p>I've done a little bit of research and have found that using setTimeout() causes a bad memory leak, as seen on <a href="http://developer.appcelerator.com/question/71241/memory-leaks-releasing-memory" rel="nofollow">this post</a>. I'm hoping to find a remedy or an alternative.</p>
  
  <p>What I have is a small view appearing on the screen when any of my many buttons is touched. At the same time I set a timeout to fadeout the small view after 3 seconds. When the button is first pressed, I also clear the timeout so that I don't continue setting multiple ones. Though now while analyzing my code I see that I'm setting an interval and clearing a timeout. Not sure if this is part of my issue. It looks like this:</p>
  
  <pre><code>var Modal = Titanium.UI.createView({
      width:151,
      height:83,
      owner: null,
      myView: null,
  });
  
  var modalTimer;
  var addModal = function(){
      clearInterval(modalTimer);
      theView.add(Modal);
      modalTimer = setTimeout( function() {
          removeModal();
          changeTurn();
  },3000);
  }
  
  playerButton.addEventListener('click',function(){
      addModal(); 
  });
  </code></pre>
  
  <p>Thanks!!!</p>