r/programming • • Oct 12 '17

JavaScript's Promise Leaks Memory

https://alexn.org/blog/2017/10/11/javascript-promise-leaks-memory.html
26 Upvotes

19 comments sorted by

View all comments

11

u/freebit Oct 12 '17

It's not true. The title is misleading.

8

u/[deleted] Oct 12 '17

What should it say?

Should be more like node promises leak memory in certain scenarios?

12

u/evaned Oct 12 '17

leak memory

I'm not even convinced it's a memory leak. In a GC'd language that would mean a runtime or GC bug. I don't really fully understand what is going on, but it doesn't sound to me like that is what is happening. It sounds like it's just chaining a bunch of objects together and because everything is still accessible it's not able to clean things up. But if everything is accessible, it's not a leak.

(I've heard the term "memory drag" used for objects that could be cleaned up from a program semantic view but aren't, but that aren't actually garbage. Using "memory leak" for that makes it harder to talk about both that and actual memory leaks.)

10

u/freebit Oct 12 '17

I'm not convinced either. It just looks like an incorrectly used(abused?) promise and a bunch of recursion that uses up all memory.