The code space is occupied by the actual code implementations data, while the stack has the data on integer values that reference to the heap items. The heap memory can now be cleaned up to create more memory space without losing important data.Malloc freeing.The process of malloc freeing of memory space is also referred to as garbage collection. This term comes up because the process involves the collection of all data that is not referenced and eliminating it. There are two types of garbage collection systems; the easy scavenge sweep and mark-sweep. Scavenge sweep is quick and reducing the downtime when your application is not running because of maintenance but it is not thorough.
The mark-sweep, on the other hand, takes longer and gets rid of all the unwanted data.As we have now learned how you will get the amount of free memory on the server in which Node.Js is running you can now enjoy using the app without crashing it. However, you need to be careful when cleaning data not to lose important information.