For visitors, if they log in to your website, the browser will crash immediately. I think this is intolerable to everyone. Here is a summary of the reasons why the website causes the browser to crash:
1. Memory leak
Let’s talk about memory leaks first. There are two situations when a website crashes due to a memory leak, the server crashes and the browser crashes. The problem caused by a memory leak is obvious, it causes the reference to the allocated memory to be lost, and the process will continue to use the memory as long as the system is still running. The result of this is that programs that once occupied more memory will reduce system performance until the machine stops working completely and the memory will be completely cleared.
Apache’s web server is written in C/C. Needless to say, there is a memory leak problem in C/C. There is unrecoverable memory in the system, which sometimes causes insufficient memory or system crash. In Java, a memory leak means that there are some allocated reachable but useless objects. These objects will not be recycled by GC, but they occupy memory.
On the client side, memory leaks caused by JavaScript may also cause the browser to crash. The more authoritative articles about memory leaks in JavaScript include "Memory leak patterns in JavaScript" and "Understanding and Solving Internet Explorer Leak Patterns》.
JavaScript is a garbage collector (GC) language, which means that memory is allocated to an object based on its creation and will be reclaimed by the browser when there are no references to the object. According to the article "Fabulous Adventures In Coding": "JScript uses a nongenerational mark-and-sweep garbage collector.", "nongenerational mark-and-sweep" can be used Understood in this way, the browser does not use pure garbage collection to process JavaScript, but also uses reference counting to handle memory for Native objects (such as Dom, ActiveX Object).
In a reference counting system, each referenced object keeps a count to know how many objects are referencing it. If the count reaches zero, the object is destroyed and the memory it occupied is returned to the heap. When objects refer to each other, a circular reference is formed. Browsers (IE6, Firefox2.0) can correctly handle circular references between pure JavaScript objects, but due to the reference counting system, mutual references Objects cannot be destroyed because the reference count can never be zero, so the browser cannot handle circular references between JavaScript and Native objects (such as Dom, ActiveX Object). Therefore, when we have a circular reference between Native objects and JavaScript objects, memory leaks will occur.
Simply put, the browser uses reference counting to handle memory for Native objects, and reference counted objects cannot be destroyed. Circular references involving Native objects will cause memory leaks. Using the following example and understanding this sentence, you can basically understand the memory leak caused by JavaScript.
Another situation is in closures. When we encounter closures and bind event response codes to Native objects, it is easy to create Closure Memory Leak. The key reason is the same as the former, which is also a circular reference across JavaScript objects and Native objects. It's just that the code is more hidden.
Some memory leaks, such as closure memory leaks, may be difficult for us to detect. To detect memory leaks, we may refer to "Javascript Memory Leak Tool Use".
2. Complex web page code and browser bug
The emergence of a large number of personal websites and low-quality website codes has resulted in a general lack of support for browsing standards. If you happen to encounter some bugs in the browser, the browser rendering engine will make errors when processing these web page codes, such as crashing. Loop or direct crash, etc.
HTML code causes website to crash
This is an HTML structure error that causes IE6 to crash. Adding any characters before or after
|
CSS code that crashes IE7
This bug comes from Stealing Rice. It only exists in IE7. It is estimated that it causes IE7 to crash when processing omitted words.