|
2 | 2 | // @name Minimize Memory Usage |
3 | 3 | // @author jterror |
4 | 4 | // @homepageURL https://github.com/update692/firefox |
5 | | -// @version 1.0 |
| 5 | +// @version 1.1 |
6 | 6 | // @include main |
7 | 7 | // @onlyonce |
8 | 8 | // ==/UserScript== |
9 | 9 |
|
10 | 10 |
|
11 | 11 | (function () { |
12 | | - console.log(">>>>: Minimize Memory Usage: START"); |
| 12 | + window.console.log(">>>>: Minimize Memory Usage: START"); |
13 | 13 |
|
14 | 14 | const threshold = 1000; // script is activated only when Firefox uses (megabytes) or more RAM |
15 | 15 | const minz_limit = 500; // minimize memory when relative RAM consumption exceeds (megabytes) |
16 | 16 | const poll_interval = 30000; // check RAM consumption value every (milliseconds) |
17 | 17 | const poll_number = 3; // how many RAM consumption values to aggregate for decision |
18 | 18 | // must be less than poll_interval |
19 | 19 | const cooldown_time = 5000; // give (milliseconds) for RAM level to stalilize after minimizing |
20 | | - const debug_beep = true; // sound beep when memory is cleared |
| 20 | + const debug_beep = false; // sound beep when memory is cleared |
21 | 21 | const beep_time = 0.1; // beep duration (seconds) |
22 | 22 | const round_mb = 20; // round RAM values to (megabytes) |
23 | 23 |
|
|
61 | 61 | if (debug_beep) doBeep(); |
62 | 62 | Services.obs.notifyObservers(null, "child-mmu-request"); |
63 | 63 | Mgr.minimizeMemoryUsage(() => { |
64 | | - console.log(`>>>>: Memory minimization completed (${new Date().toISOString()})`); |
| 64 | + window.console.log(`>>>>: Memory minimization completed (${new Date().toISOString()})`); |
65 | 65 | setTimeout(async () => { |
66 | 66 | const megabytes = await getRAM(); |
67 | 67 | current_level = megabytes; |
68 | 68 | lower_level = megabytes; |
69 | | - console.log(`>>>>: level updated: ${megabytes}`); |
| 69 | + window.console.log(`>>>>: level updated: ${megabytes}`); |
70 | 70 | }, cooldown_time, "timer_cooldown"); |
71 | 71 | }); |
72 | 72 | } |
|
171 | 171 | log_msg += " : reset--"; |
172 | 172 | doReset(); |
173 | 173 | } |
174 | | - console.log(log_msg); |
| 174 | + window.console.log(log_msg); |
175 | 175 | }, poll_interval, "timer_poll"); |
176 | 176 | })(); |
0 commit comments