Home > Web Front-end > JS Tutorial > js memory release problem_javascript skills

js memory release problem_javascript skills

WBOY
Release: 2016-05-16 18:28:48
Original
1083 people have browsed it

CollectGarbage();
setTimeout("CollectGarbage();", 1);

The reason why setTimeout() is used here is because it can completely recycle all current objects and prevent references between variables from causing release failure. , can be used as a safeguard measure. Logically speaking, it will not be implemented here.

When using it, please note that it must be executed after all functions have been executed, otherwise, setTimeout(), setIntervalue(), etc. will not work properly.

In addition, avoid using it indiscriminately. Generally speaking, emptying the top-level object "var xxx='ss';xxx=null;" can help the browser release memory. IE releases it when it is minimized and closed. Therefore, leaving the IE window open for a long time will cause IE to slow down when it is opened again.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template