memory leak when using uploadify in IE

65 Views Asked by At

I tried this in IE. Create a uploadify control (flash version) and destroy it, do these again and again. But it seems that the memory allcated doesn't release after method destroy called.

libs

<script src="Scripts/jquery-3.1.1.js"></script>
<link href="uploadify/uploadify.css" rel="stylesheet" />
<script src="uploadify/jquery.uploadify.js"></script>

html

<button id="btnAdd">add</button>
<button id="btnRemoveLast">remove last</button>
<div id="container">
    <!--we will place uploadifies here-->
</div>

js

    <script>
        $(function () {            

            $('#btnAdd').click(function () {
                add();
            });
            $('#btnRemoveLast').click(function () {
                removeLast();
            });

            var count = 0;
            function removeLast() {
                if (count > 0) {
                    $('#uploadify' + --count).uploadify('destroy');
                }
            }
            function add() {
                var elem = $('<div id="uploadify' + count++ + '"></div>');
                $('#container').append(elem);
                elem.uploadify({
                    height: 30,
                    swf: '/uploadify/uploadify.swf',
                    width: 120
                });
            }
        });        
    </script>

Any answers will be appreciated, and thank you for pardoning my English:)

2

There are 2 best solutions below

0
bgauryy On

Looks like another IE "fun". If the problem is the the same for the problem that I know, nullify will be the answer. In IE there is a bug with the GC, so you need to "release" yourself references and scope variables.

Try this:

 var upToDestroy =  $('#uploadify' + --count);
upToDestroy.uploadify('destroy');
upToDestroy = null;
0
GrayBird On

I'm sorry for my late anwer. I saw the question after my off work.I have found the the solution of the problem after i saw the uploadify's source code. it seems worked at my IE11 .Pay attention to the queueid. enter image description here

However Why not try the function CollectGarbage().Finally,Please forget for my poor english.