Last modified: 2013-07-09 09:52:35 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T51626, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 49626 - jquery.makeCollapsible causes memory leaks in all major browsers
jquery.makeCollapsible causes memory leaks in all major browsers
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
JavaScript (Other open bugs)
unspecified
All All
: Low normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks: 35785
  Show dependency treegraph
 
Reported: 2013-06-16 00:25 UTC by pecoes
Modified: 2013-07-09 09:52 UTC (History)
5 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description pecoes 2013-06-16 00:25:09 UTC
I do not know the full scope of this bug, but it occurs reproduceably on Special:RecentChanges. Below is some reproduce code. It's meant to be tested via the browser console. As you will see the jQuery cache grows with each iteration. As there tends to be a lot more than one collapsible section on that page, the leakage tends to become quite drastic over time, if you run a script that continuously refreshes the page like this one:

http://dev.wikia.com/wiki/AjaxRC

(function test (t) {
    $('#mw-content-text').empty();
 
    $(
      '<table class="mw-collapsible mw-collapsed mw-enhanced-rc">\
        <tbody>\
          <tr>\
            <td>\
              <span class="mw-collapsible-toggle">\
                <span class="mw-rc-openarrow">\
                  <a href="#" title="Show details (requires JavaScript)">\
                    <img src="http://slot1.images.wikia.nocookie.net/__cb62189/common/skins/common/images/Arr_r.png" width="12" height="12" alt="+" title="Show details (requires JavaScript)">\
                  </a>\
                </span>\
                <span class="mw-rc-closearrow">\
                  <a href="#" title="Hide details">\
                    <img src="http://slot1.images.wikia.nocookie.net/__cb62189/common/skins/common/images/Arr_d.png" width="12" height="12" alt="-" title="Hide details">\
                  </a>\
                </span>\
              </span>\
            </td>\
            <td>\
              &nbsp;&nbsp;Test&nbsp;' + t + '&nbsp;&nbsp;</td>\
            <td>\
              <button>reload</button>\
            </td>\
          </tr>\
          <tr><td colspan="3">hidden line</td></tr>\
          <tr><td colspan="3">hidden line</td></tr>\
          <tr><td colspan="3">hidden line</td></tr>\
        </tbody>\
      </table>'
    )
    .appendTo('#mw-content-text')
    .makeCollapsible()
    .find('button')
    .click(function () {
        var c = 0, i;
        for (i in jQuery.cache) c++;
        console.log('Test', t, 'jQuery.cache', c);
        test(t + 1);
    });
}(1));
Comment 1 Bartosz Dziewoński 2013-06-16 12:23:19 UTC
Confirming. This seems to be caused by unconditionally creating the default toggler with its event handler even if it's not actually inserted into the document (custom togglers are used, like in your example).

Commenting out lines 292-295 in /resources/jquery/jquery.makeCollapsible.js in the current MW master fixes the leak (although obviously breaks the code). It should be a reasonably easy fix to not create the toggler if not needed.
Comment 2 Gerrit Notification Bot 2013-06-16 13:10:53 UTC
Related URL: https://gerrit.wikimedia.org/r/68949 (Gerrit Change I0c92e5c28a66c6a6469e107593dc9b6d3baa8a10)
Comment 3 Gerrit Notification Bot 2013-07-06 13:27:03 UTC
Change 68949 merged by TheDJ:
jquery.makeCollapsible: fix jQuery memory leak

https://gerrit.wikimedia.org/r/68949

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links