rNeomy / auto-tab-discard

Use native tab discarding method to automatically reduce memory usage of inactive tabs
https://webextension.org/listing/tab-discard.html
Mozilla Public License 2.0
906 stars 79 forks source link

Discard active tab if memory exceeds XXX #383

Open AJolly opened 1 month ago

AJolly commented 1 month ago

It'd be really useful to be able to discard active tabs if the memory reaches a certain level, not just background tabs. I frequently have lots of "active tabs", but not active windows, if that makes sense.

Chealer commented 1 month ago

Please clarify what you mean by "the memory reaches a certain level".

AJolly commented 1 month ago

The existing feature in number.mjs:

It doesn't seem to trigger on active tabs. Admittedly debugging's a bit annoying, since the log function doesn't store the line where the log was triggered from.

// is the tab using too much memory, discard instantly
      if (prefs['memory-enabled'] && meta.memory && meta.memory > prefs['memory-value'] * 1024 * 1024) {
        log('forced discarding', 'memory usage');
        discard(tb);
        continue;
      }

//it doesnt discard because of this.
      // in case the tab is not excluded by the initial query
      if (tb.active) {
        log('discarding aborted', 'tab is active', tb);
        exceptionCount += 1;
        icon.reset(tb);
        continue;
      }