I just found & reported a memory leak issue on a website.

When i tried to load the page, my system's RAM filled up entirely in about 5 seconds, after which the swap space began to fill up at a pretty scary speed, and about 20 seconds after typing the URL in my browser's address bar, my computer was totally unusable (switching TTYs and killing the browser process took about 15 minutes because the thing was so damned slow - couldn't hard reboot, had some unsaved work open).

I was wondering, how can my browser allow this kind of thing to happen? Shouldn't there be some safeguard against this? The "a script on this page is slowing down your browser" alert did pop up, but way too late and the browser was already totally unresponsive so i couldn't click on the "stop script" button anyway.

I know there is this issue on the topic, but i'm more interested into how it could be prevented rather than why it happens.

For reference, i'm using Firefox, but there was comments of the same thing happening in Chrome on the issue report i sent, so i believe it's a universal problem.

closed as primarily opinion-based by gnat, GrandmasterB, Doc Brown, Bart van Ingen Schenau, user1118321 Aug 11 at 17:13

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    How would you distinguish a memory leak from a web application that does something complicated and thus legitimately requires a lot of memory? – whatsisname Aug 10 at 14:59
  • @whatsisname perhaps the huge, rapid increase in memory usage up to what could be safely considered as "abnormal" levels? – Squared Aug 10 at 15:06
  • 2
    How does the browser manufacturer coordinate with the website author and the end user as to what is "abnormal"? – Caleth Aug 10 at 15:09
  • 1
    The real culprit is the OS - it should be designed to reserve enough resources to run its I/O properly (without being a resource hog). – Lawrence Aug 10 at 15:33
  • 1
    Don't know if there is a browser which supports to set memory limits for scripts, but there are solutions for every major OS to set memory limits for a certain process. Try to google "limit memory usage of a process [windows|linux|mac]", and you will find a solution. However, we cannot tell you why a certain feature is not available in a certain piece of software - that is definitely not a good question for this Q&A site, which is not a discussion board, sorry. – Doc Brown Aug 10 at 17:48