Skip to content

Javascript Memory Leaks - setTimer() & setInterval() #127951

Discussion options

You must be logged in to vote

Hi @itsmichaelhagen , wow that's a lot of global variables, I'm beginning to suspect that the problem you have isn't due to a memory leak but rather a general performance problem, while variables don't inherently cause a memory leak, having a lot of global variables can affect performance. You should limit their usage as much as possible and instead use local variables inside functions or blocks. Encapsulation comes in handy in such cases, encapsulating variables and related functions inside objects or modules to limit their scope and improve maintainability. Another thing that can help improve performance is to regularly clear or reset variables that contain lots of data which is the app…

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@itsmichaelhagen
Comment options

@davevad93
Comment options

@itsmichaelhagen
Comment options

@davevad93
Comment options

Answer selected by itsmichaelhagen
@itsmichaelhagen
Comment options

@davevad93
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Programming Help Programming languages, open source, and software development.
2 participants