Memory
Causes of Memory Leaks
What are memory leaks?
In JavaScript, memory is automatically allocated, referenced, and released for you.
A memory leak occurs when the memory can't be released.
Wave
Memory starts at 0, gets allocated, and then released back down to 0
Upward ramp that flattens out
Memory starts at 0, gets allocated, and you continue to use it throughout the life of your application
Jigsaw
Memory keeps growing and growing and growing and never goes down
Common causes
Accidental global variables:
Forgotten timers:
Storing a DOM node in a variable and then removing it:
Chrome Task Manager & Snapshots
Chrome Task Manager
A quick at-a-glance way to check for memory leaks is to open Chrome Task Manager under "More Tools" (not part of dev tools).
By adding the JavaScript memory column, you'll know there's a memory leak if the memory allocated for your site goes up and up.
Snapshots
The Performance tab helps you spot a memory leak. The Memory tab helps you figure out what's causing the memory leak.
WIP...
Last updated