javascript memory leaks

javascript memory leaks


i am doing something like this
    
  1. //dom
  2.     <div id='parent'>
  3.     </div>
  4.     //js
  5.     var _doSomeThing=function()
  6.     {
  7.     //some codes
  8.     }
  9.     $(function(){
  10. //appending div and binding methods to span
  11.     $('#parent).append('<span>1</span>');
  12.     $('#parent).append('<span>2</span>');
  13.     $('#parent span').bind('click',_doSomeThing);
  14.     });
  15. function _clearDiv()
  16. {
  17. //clear div
  18. $('#parent).html('');
  19. }
  20. //sometime in future, call clear div
  21. _clearDiv();

now my question is, binding events to dom and later just removing the
elements from dom leads to memory leakage.

I read some where that doing this will lead to memory loss. As i just cleared the
div without unbinding the events.
my question is if i use $('#parent').empty()- to clear the div is this will
avoid memory leakage
if yes how to solve this problem.