[webkit-dev] innerHTML and removeChild ... not freeing memory

Purushottam Sholapur purushottam.sholapur at gmail.com
Wed Mar 25 08:48:58 PDT 2009

Hi all,

I am using QT/Webkit-4.5 (embeded version) on linux. I am trying to use
createElement, innerHTML, appendChild and later removeChild.

UI Output is perfectly fine. But when I do removeChild, div momory is not
freed. Is there anything wrong with the code. Since the div contains image,
lot of memory is hogged and not freed.

------------Below is the code...
Click on "Add Some Elements" to add the div to innerHTML
Click on "Remove the div" to remove the div
        <title>Test script</title>
        <script language="javascript">
        function removeElement(divNum) {
            var divIdN = 'my'+divNum+'Div';
            var olddiv = document.getElementById(divIdN);
            olddiv = null;
        function addElement() {
            var ni = document.getElementById('myDiv');
            var numi = document.getElementById('theValue');
            var num = (document.getElementById('theValue').value -1)+ 2;
            numi.value = num;
            var newdiv = document.createElement('div');
            var divIdName = 'my'+num+'Div';
            newdiv.innerHTML = 'Element Number '+num+' has been added! <a
href=\'#\' onclick=\'removeElement('+num+')\'>Remove the div
"'+divIdName+'"</a>'+'<img src="
            ni = null;
            newdiv = null;
<input type="hidden" value="0" id="theValue" />
<p><a href="javascript:;" onclick="addElement();">Add Some Elements</a></p>
<div id="myDiv"> </div>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20090325/230c994c/attachment.html>

More information about the webkit-dev mailing list