DEV Community

loading...

Discussion on: Run a function periodically in vanilla Javascript

Collapse
asolace profile image
Jack H.

Will this cause a memory leak if it's run indefinitely?

Collapse
singh1114 profile image
Ranvir Singh Author

@asolace I don't think so, all the variables are initialized inside the tellTime function. So, they should be used only when the program runs after each instance. Once the function ends, the garbage collector should remove them from the heap.

stackoverflow.com/questions/140341...

Collapse
singh1114 profile image
Ranvir Singh Author

@asolace @alexandrusimandi updated the post ranvir.xyz/blog/running-a-function... with the answer to the memory leak. Hope it helps.