B
B
BestJS2016-11-22 16:33:36
Node.js
BestJS, 2016-11-22 16:33:36

Why doesn't DELETE work in NodeJs?

Here is the code

var a, b, c, d, e, h;
b = new Array(10000000).join('lalalalalalalalalalalala');
d = new Array(10000000).join('lalalalalalalalalalalala');
c = new Array(10000000).join('lalalalalalalalalalalala');
e = new Array(10000000).join('lalalalalalalalalalalala');
h = new Array(10000000).join('lalalalalalalalalalalala');
a = new Array(10000000).join('lalalalalalalalalalalala');
aa = 5


delete a, b, c, d, e, h, aa;

console.log(aa)

Here is a screenshot of how it works:
https://yadi.sk/i/Qx2U5ATzzDvYp
And even so, nothing is deleted from memory https://yadi.sk/i/w9Pz7wzvzDwqb
Why was nothing deleted from memory?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vitaly, 2016-11-22
@BestJS

As far as I know, Node.js uses a garbage collector that monitors the device's RAM and triggers cleanup at a certain overflow level. Try to run an infinite loop, inside which the object is created and then nulled.

Y
Yuri Puzynya, 2016-11-28
@3y3

If you want extreme sports, you can read about the --expose-gc flag.
It will help you clean memory at the right time, but is not recommended for production use.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question