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.