I have created an HTML page to understand how removing an element works.
Code :
remove is a new function. It's a shortcut, making it simpler to remove an element without having to look for the parent node. It's unfortunately not available on old versions of Internet Explorer so, unless you don't want to support this browser, you'll have to use removeChild or use a polyfill.
The reason the child element is kept in memory is your code keeps a reference to it.
If you do
childDiv = null;
then there's no reference pointing to it and the browser can free the memory.