I just want to understand what will happen if we call the close method in NodeJS's http.Server object. (I think this is object is also inherited by ExpressJS server object).
I have the following questions:
close()
method does it flush all memory of the previous server object?close()
method and tried to create a new server object with the same port and host as of the previous server object, can we reuse the port and host address again?Thanks for the reply.
1) That's probably a matter of implementation, but I'd be surprised if it doesn't at least make all the allocated memory from the object eligible for garbage collection.
2) Yes, as long as you wait for the previous server to send a close
event; until then, the previous server won't be finalized.
3) Not if there's more code to execute or there are events pending.