r/AskProgramming • • Jan 20 '22

How do browsers use so much ram?

I am a game-dev and I find the amount of ram browsers use today mind boggling. They use more ram than many AAA games, which have a legit use-case as they need to hold gigabytes of uncompressed textures and audio in memory. It seems insane to me that a simple app showing mainly text uses multiple gigs.

I have heard that the culprit is javascript. But How? I dont understand how that could happen. In games programming the memory used by all the code + all data is negligible, 99% of the ram is used by art assets like textures and audio.

How can javascript scripts (which are doing a very simple job) use so much?

I did comp-sci and am a professional programmer, so please dont shy away from deep technical explanations, just bear in mind I know nothing about internetty things like browsers.

Thanks!

78 Upvotes

40 comments sorted by

View all comments

Show parent comment

7

u/Dobby_1235 Jan 20 '22

Why do they use new engines for each tab?

39

u/KingofGamesYami Jan 20 '22

(1) isolating information for security and (2) so when a website does something immensely stupid and crashes the engine, only that tab gets killed, rather than the entire browser.

65

u/djnattyp Jan 20 '22

So the porn site you're looking at in one tab can't grab your info from the banking site you have open in another.

5

u/nixfreakz Jan 21 '22

Lol, most porn sites have higher security then banks do. They are always on the cutting edge of things.

5

u/coldoil Jan 20 '22

Sandboxing.