Tampermonkey / tampermonkey

Tampermonkey is the most popular userscript manager, with over 10 million users. It's available for Chrome, Microsoft Edge, Safari, Opera Next, and Firefox.
GNU General Public License v3.0
4.28k stars 424 forks source link

Potential Memory Leak caused by TM_backup #1357

Open SukkaW opened 3 years ago

SukkaW commented 3 years ago

Expected Behavior

The memory usage shouldn't keep climbing steady.

Actual Behavior

The memory usage keep climbing.

And from heap snapshot it seems that the TM_backup keeps being retained even after Major GC.

Specifications

Script

It seems not related to the script.

derkalle4 commented 2 years ago

Hi, I do have a similar issue on a larger user base within 91.7.1esr (32-bit & 64-bit) on Windows - Firefox on Mac OS seems to work fine (at least I have not experienced any issues over months). I did compare two snapshots after using the GM_xmlhttpRequest feature and it shows a similar view like the screenshot above. If I do not call GM_xmlhttpRequest it seems to have no effect or at least it is not that strong and takes longer.

The main concern is that the memory keeps rising over time (around 4 to 10 MB per "reload" via the http request every three minutes) and the only thing that actually helps is to close the tab and re-open it. This is more noticable on Firefox then on Chrome but within our user base of around 10.000 people we have got some reports for both (Firefox ESR and latest version as well as Chrome latest version).

However, I read in this github repo that there is some memory leak avoidance already implemented which takes place when switching tab and waiting some seconds. This seems to work for Chrome but not for Firefox to actually reduce the memory leak nor does it have any effect when leaving the tab open. That bug was because of reloading the tab via F5 which we used to do in earlier versions. We switched to a feature where we avoid reloading but getting the data via GM_xmlhttpRequest by ourselves. This seem to resolve most of the memory leak issues but introduces another.

I do not know how to further track this issue down. TM_Back