-
Notifications
You must be signed in to change notification settings - Fork 20.6k
IE8 iframe memory leak with non-detached click event #1840
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
How many iframes do you create to make this a real problem? |
2 pages (1 with 1 iframe): <!DOCTYPE html>
<html>
<head>
<style>
html, body, iframe {
margin: 0;
padding: 0;
border: 0;
height: 100%;
width: 100%;
}
</style>
</head>
<body>
<iframe src="leak.html"/>
</body>
</html> leak.html: <!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8" />
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
</head>
<body>
<button onclick="navigate()">Cerrar</button>
</body>
<script>
function navigate() {
var form = document.createElement("form");
while (document.body.firstChild) {
form.appendChild(document.body.firstChild);
}
document.body.appendChild(form);
form.submit();
}
</script>
</html> |
Right, so one |
No. The problem is that those lines of code (and only those) are creating one |
Something similar was removed in b8fc9d1, but your code also removes the binding for the cloned div. Is that necessary, or does simply unbinding for the original div happen to fix the issue? |
It is necessary according to Microsoft's documentation (remove all the attached events in parent-less nodes). That piece of jQuery's code is a simple test to detect if the browser is able to clone not only the node itself, but also its attached events. Detach them is transparent and fully functional and backward-compatible. |
Yes, it does seem like both elements would need to have the event handler detached, but in that case the code I referred to above was not preventing a memory leak since the cloned element still had the handler. It's too bad we don't have a good way to do automated tests on these issues. |
How about we dump our direct feature detect and switch to an indirect detect? That reduces this whole mess to this without any resource leaks or cleanup: support.noCloneEvent = !!div.addEventListener && !!div.attachEvent; It could be even simpler but we need the second part for Opera 12 support if the comment is right. |
We're dropping Opera Presto support so that shouldn't matter. |
Fixes gh-1840 This feature detect could be simplified now that the only supported browser with this problem is IE8.
Landed faf295a to fix |
Just as a note: this regression was caused by #1518 |
If you load jQuery 1.X (i'm testing with edge) inside an iframe, alone, and reload the content (eg. by submiting a dummy form), you could see a memory leak under IE8 (not IE10+ with IE8 compat, no. A really production IE8 legacy enterprise browser).
The bad lines are:
By changing them for something like the following...:
... the memory leak dissapears, and the test continues working as espected.
(- sorry about my non-linted code -)
One of the known solutions for the well-known issues with iframes, memory leaks, events and IE8 is to detach all the events before the garbage collection.
The text was updated successfully, but these errors were encountered: