Why isn't JS memory leak happening?

  • 0
    function bb() {
      const parent = () => ({
      	testFn: parent
      return parent
    const a = { c: bb()() };
    setInterval(() => {
    }, 2000)
    setTimeout(() => {
    	delete a.c;
    }, 6000)

    fiddle: https://jsfiddle.net/2xbtghpm/22/

    Although logic dictates what should be. Parent contains an object with a reference to itself. We deleted it ... Or is there still a memory leak, but I'm not checking it correctly?
    JavaScript Anonymous, Feb 9, 2020

  • 1 Answers
  • 0
    JS language with garbage assembly. When unused objects are removed, the entire graph is removed. Circular references do not lead to memory leaks. What would arise from there must be exactly the path from one of the roots to the object.
    Isla McKinney

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!