In the above article by Raymond Chen, he mentions how when a process exits, it is better to let the OS just clean up the resources, as opposed to manually calling free on it. He claims that an application he regularly uses takes minutes at nearly 100% cpu usage just to delete every last byte of memory manually. I know that Windows will do the work of updating its internal structures to indicate pages/handles used by the process as free on process exit, but I am unsure as to why this would be any faster than manually freeing the memory.
If Windows needs to free the memory instead of us, isn't it still going to take a similar amount of time to do the same operations that we would do manually. For example, wouldn't it still need to go through our windows handle table and delete all the outstanding Windows objects, like files and windows. Similarly, if allocating with VirtualAlloc won't it still need to go through all the pages in our processes page table and mark them as not-in-use. I may be misunderstanding, but Raymond Chen's article makes it sound like the savings by just calling exit can be huge (for processes that allocate a lot), but I don't see why that is.
My thought is this may matter if you have pretty complicated data structures, which you need to traverse to free memory e.g. a simple example would be a 2D array or if you make heavy use of a Heap as opposed to big block allocations, like arenas. I suppose things like closing Handles matters, since it requires multiple calls into the Kernel to manually free them one by one vs just letting the kernel do the cleanup of every handle in ExitProcess.