Skip to content

memory leak with iframe with same origin  #311

Closed
@sixinli

Description

@sixinli

Hi,

I have a site page that has an iframe referencing another page under the same origin/host, both pages use interact@1.2.6. I have noticed that there's a leak when the iframe is destroyed, the memory is not freed.

Here is a simple repo:
index.html has an iframe referencing frame.html and has a button to toggle on and off of the iframe:

<html>
 <head>
    <script type="text/javascript" src="https://code.jquery.com/jquery-git.js"></script>
 </head>
 <body>
    <script src="interact.js"></script>
    <iframe src="/frame.html"></iframe>
    <button id="mybutton">click me</button>
    <script type="text/javascript">
        var on = true;
        $("#mybutton").click(function() {
            if (on) {
                $("iframe").attr("src", "about:blank");
            } else {
                $("iframe").attr("src", "/frame.html");
            }
            on = !on;
        })
    </script>
 </body>
</html>

and inside the frame.html:

<html>
 <head></head>
 <body>
    <h2> im an iframe </h2>
    <script src="interact.js"></script>
    <script type="text/javascript">
        var array = [];
        for (var i = 0; i < 1000000; i++) {
             array.push(i);
        }
    </script>
 </body>
</html>

and here is screen shot of the heap snapshots:
snapshots
The odd number (1,3,5) snapshots are when the iframe is on, and the even number ones are when the iframe is off. Notice for example in snapshot2 (when the iframe is off), the memory usage is still the same when it should be lowered.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions