jquery/jquery — pull request #1664 by jbedard (2014-09-24 06:46:26+00:00)
Title: Data: avoid using delete on DOM nodes

This is similar to https://github.com/jquery/jquery/pull/1662 but for jQuery 1.x which reproduces https://code.google.com/p/chromium/issues/detail?id=378607 in `cleanData` by using `delete` on DOM nodes. I have found this issue worse then the jQuery2 version because cleanData often runs on large groups of nodes at once (such as when changing pages in a SPA). If every node (with data) reproduces the chrome issue it can cause memory usage to spike very high and cause significant performance issues. I have seen pages spike from 15m to 150m while transitioning pages in a SPA, combined with https://code.google.com/p/v8/issues/detail?id=2073 that use case often crashes the browser.

The easiest way to reproduce it, in the chrome console (on any page, a blank one makes the memory snapshot easier to read):
```
var div = document.createElement("div");
div.jQuery123 = 1;
*heap snapshot #1*
delete div.jQuery123;
*heap snapshot #2*
```
If you find the detached div element in the heap snapshot it is about 150 bytes in snapshot 1, in snapshot 2 I'm normally seeing it around 6300 bytes.

I'm having trouble testing this properly in oldIE so I'm not 100% sure if the current commit covers oldIE correctly. I think setting `elem[ $.expando ] = undefined` will just change the expando attribute to `jQuery###="undefined"` in the DOM, so maybe we need a support test for that and an extra `.removeAttribute( internalKey )`?