News for hackers. Stuff that matters.
Re:JavaScript and Node performance coding tips to make appli... by mulrian on Tuesday March 13, 2018 @06:10AM (#16574889)
Second point is, global variables are not cleared by the garbage collector. So if you continuously add more and more global variables (which are not of future use), it will cause a memory leak.

Errr...

Re:JavaScript and Node performance coding tips to make appli... by Skinney on Tuesday March 13, 2018 @06:28AM (#16574969)
It's an easy thing to do in JS, it happens if you forget the `var`.
Re:JavaScript and Node performance coding tips to make appli... by Klathmon on Tuesday March 13, 2018 @06:48AM (#16575069)
only when not in strict mode, which is becoming more and more rare, especially in javascript codebases (as opposed to one-off scripts)
Re:JavaScript and Node performance coding tips to make appli... by aetherspawn on Tuesday March 13, 2018 @06:24AM (#16574941)
I think this is true because they hold a reference in window.
Re:JavaScript and Node performance coding tips to make appli... by mulrian on Tuesday March 13, 2018 @06:35AM (#16575011)
Sure that will prevent gc, but that doesn't mean it's a memory leak
Re:JavaScript and Node performance coding tips to make appli... by dspillett on Tuesday March 13, 2018 @07:45AM (#16575324)
It is if the variable is accidentally in global scope due to hoisting if it is not explicitly defined in a finer scope. Not an issue in strict mode, you'll get a reference error instead of an implied global.
Re:JavaScript and Node performance coding tips to make appli... by rootlocus on Tuesday March 13, 2018 @07:24AM (#16575248)
If you're never going to use it again, and you're never going to free it, it's a memory leak.
Re:JavaScript and Node performance coding tips to make appli... by Sawamara on Tuesday March 13, 2018 @09:35AM (#16575944)
No, it is not. A memory leak has to grow. Without the leak part, it is just ...allocated memory.