Home > Web Front-end > JS Tutorial > body text

What are the operations that cause memory leaks?

hzc
Release: 2020-06-28 13:21:05
Original
2611 people have browsed it

The operations that cause memory leaks are: 1. If the first parameter of setTimeout uses a string instead of a function, it will cause a memory leak; 2. Closures, console logs, loops [between two objects When they are referenced and retained with each other, a cycle will occur, which will cause a memory leak.

What are the operations that cause memory leaks?

Memory leak refers to any object that persists after you no longer own or need it.
The garbage collector scans objects periodically and counts the number of other objects that reference each object. If an object has 0 references (no other objects refer to it), or the only reference to the object is circular, then the object's memory can be reclaimed.
If the first parameter of setTimeout uses a string instead of a function, it will cause a memory leak.
Closure, console log, loop (when two objects refer to each other and retain each other, a loop will be generated)

Recommended tutorial: "JS Tutorial"

The above is the detailed content of What are the operations that cause memory leaks?. For more information, please follow other related articles on the PHP Chinese website!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!