I read that node.js is single-threaded, so it doesn’t fork a new process or start a new thread for each http request. But then does the http module have a way of cleaning up after it closes each connection? For example, if I create an object inside the callback every time someone requests a page, does that object get destroyed once the response is served and the connection is closed?
Share
Yes this true is due to scoping.
Once you end the function the BigObject is no longer in use and gets cleaned up by the garbage collector.