by codedokode · 7y ago · 0 comments
Well, wasting 100-200 Mb for one tab is fine, but what if I have many tabs opened? Browser quickly uses up all available memory and starts swapping out other programs including a shell.
I think that browser could at least reduce memory consumption for background tabs: they don't need to run when they are in background. A browser could free everything that is not necessary, including: image decoding cache, caches to speed up DOM and CSS, canvases, compiled JS bytecode (it takes more memory than source code) and JIT'ted code, any network caches, SQlite cache. Also they could gzip text resources in memory like CSS or JS code.
Note that this approach is better than simply unloading a page like mobile browsers do. But if the user didn't input anything into a page, I think it should be fine to unload it completely after some timeout (for example, 30 minutes).
The same approach could be used with iframes. Typically they are used mostly for ads and analytics. There is no need to waste precious memory for slightly better animation of an ad banner.
I remember that many years ago Opera could handle tens of tabs with 512 Mb of memory and not get swapped out.
Tabs back then weren't full page SPAs, though.