JavaScript question detail
What are the possible reasons for memory leaks?
Memory leaks can lead to poor performance, slow loading times and even crashes in web applications. Some of the common causes of memory leaks are listed below,
- The execessive usage of global variables or omitting the
varkeyword in local scope. - Forgetting to clear the timers set up by
setTimeoutorsetInterval. - Closures retain references to variables from their parent scope, which leads to variables might not garbage collected even they are no longer used.