How JavaScript works: memory management and common memory leaks
blog.sessionstack.com
How JavaScript works: memory management and common memory leaks
1–10 of 57 posts
Re: How JavaScript works: memory management and common memory leaks
#2Re: How JavaScript works: memory management and common memory leaks
#3having stuff do stuff for you is useful until it doesnt
Re: How JavaScript works: memory management and common memory leaks
#4Re: How JavaScript works: memory management and common memory leaks
#5Wait, is #3 for real? If that's the case it seems like a huge oversight.
I am sort of surprised that `unused` is not picked up by the garbage collector in the first place though. Since JS functions are objects, shouldn't it detect an object that's not referenced during the mark and sweep?
In general, I really hate having to debug memory leaks in JS or Python. The interpreter for both will randomly allocate additional memory as it runs, so using tools like Valgrind is next to impossible. The only reliable method I've found is to pepper my code with logging statements that show what the current memory usage is, run the code like 1000-10,000 times, and see the points between which the memory usage goes up without coming down on a consistent basis. Python's built in `gc` module seems nearly useless for determining what's actually stuck in memory, and having a billion libraries that can have their own memory leaks is also not fun. These are the times I miss C: when you leak memory in C you know it because it becomes painful fast and it's usually easy to find, if your code is sane.
Re: How JavaScript works: memory management and common memory leaks
#6having stuff do stuff for you is useful until it doesnt
I agree. I strongly dislike "magic" in programming. I prefer to call it "denial" because you need to know about the complexities anyway, and "magic" often means sweeping them all under the rug.
Re: How JavaScript works: memory management and common memory leaks
#7Re: How JavaScript works: memory management and common memory leaks
#8Who is this article written for? There's a whole section on "What is memory?". If you are optimizing to remove memory leaks I really hope you already know what memory is.
Re: How JavaScript works: memory management and common memory leaks
#9Re: How JavaScript works: memory management and common memory leaks
#10https://blog.sessionstack.com/how-javascript-works-memory-ma...