3 ms·
What I don't like that modern browsers tend to trade memory for performance, i.e. get slightly better numbers in benchmarks by using significantly more memory.
by codedokode 7y ago
What I don't like that modern browsers tend to trade memory for performance, i.e. get slightly better numbers in benchmarks by using significantly more memory. For example, have you heard about image decoding cache? A browser can waste as much as 20 or 30 Megabytes to store uncompressed bitmaps, although a better solution would be not to store them at all. If the website uses too much images, then it is not a browser's problem.
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.
- saagarjha 7y ago> 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.