Node.js will do auto garbage collections ?
var objUser = new Object ();
objUser.userName = objReq.userName;
userDB.registerUser (objUser , callback) ;
In the above code I have “objUser” which will be passed as an argument to another class and it is no longer required in the present class. Still, should I have to forcefully collect it or will it do automatically.
To do it manually, Will NULL help or is there any other mechanism given by Node Framework?
objUser = null;
Node does garbage collection, but if
userDb.registerUser()retains a reference to it, yourobjUserwill not be collected. Only when no references to an object remain it will be collected. You usually don’t need to explicitly release local references by assigningnullto the variable — when your function returns, all local references are released automatically. You need to worry only about global references to your object.