Methods of "unloading" tabs

Hello,

is there a way to remove the document/web content from a tab’s linkedBrowser? Currently I am implementing a tab “unloading” feature in All Tabs Helper, using the /grab tab data/remove tab/add new tab/restore tab with data/ method inspired by Bar Tab. This method seems to be very effective, although it is a bit clumsy. I have explored other tab “unloading” implementation done by other addons, but from what I see they are either messy and fragile, or just not very effective.

Maybe this is an age-old question, but I am looking for the least impacting way to unload tabs especially a way that actually unloads the tab in place, while still getting the effectiveness I am getting with my current method. I see a tab/browser is loaded using nsIWebNavigation interface but I find no corresponding “unload” method. I have naively experimented with approaches such as removing the docShell from the browser, but I am not having success.

Any input on this would be much appreciated.

Allasso

1 Like

An “empty” tab is just about:newtab or about:blank. You might want to decide whether to provide a specific setting for how an “unloaded” tab should look.

Yeah, one might think just doing tab.linkedBrowser.loadURI("about;blank") would work, but according to my tests it makes little difference in the memory consumption compared to destroying/creating the tab.

The unloaded tab looks just like the tab would look if you just started up a new session:

let state = SessionStore.getTabState(tab);
// remove tab and create a new one in its place
SessionStore.setTabState(newtab,state);
1 Like

Reading between the lines, I think you’re concerned with the wrong things. Make it work, don’t leak, and let Firefox worry about resource consumption. Firefox remembers a great many things, not necessarily lost when you reload a tab or even when you completely remove it (eg. restore recently closed tabs). Don’t try and micro-manage the caching, garbage collection, and all the other things going on behind the curtain, you’ll just make a mess.

1 Like

Ah, but then, what would be the point of development? :slight_smile: