I am writing code for JS. And I need to know how works memory in JS when I remove big Object.
var a = new Object();
a.b = new Object();
a.b.c = new Object();
a.b.c.d = new Object(); 
a.b = undefined; // Is it delete a.b.c and a.b.c.d or not?
I am writing code for JS. And I need to know how works memory in JS when I remove big Object.
var a = new Object();
a.b = new Object();
a.b.c = new Object();
a.b.c.d = new Object(); 
a.b = undefined; // Is it delete a.b.c and a.b.c.d or not?
 
    
     
    
    If there are no pointers to an object it will be garbage collected.
Since the only pointer to a.b.c was in a.b, a.b.c will be garbage collected. Same situation with a.b.c.d.
 
    
     
    
    JavaScript is automatically garbage collected; the object's memory will be reclaimed only if the Garbage Collectior decides to run and the object is eligible for that.
The delete operator or nullify your object ( a.b = undefined; )has nothing to do with directly freeing memory (it only does indirectly via breaking references). See the memory management page for more details).
