Jump to content

User:Mdaniels5757/chromeAutoGarbageCollect.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Mdaniels5757 (talk | contribs) at 20:15, 16 July 2020 (Create). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// This script just runs Chrome's garbage collector every wait_ms milliseconds
//		(where wait_ms > 60000).
// Made because there's some sort of memory leak in one script/gadget or another
// and I can't be bothered to figure out which.
// The relevant Chrome flag must be enabled for this to work.

var wait_ms = 61000;

function runGC() {
	var now = new Date();
	
	setTimeout( function () {
		runGC();
	}, wait_ms - (now.getUTCSeconds()*1000 + now.getUTCMilliseconds() ) );
	
	window.gc();
}

runGC();