Just for fun I created a project that created about 5 GB of memory and did not delete it. As long as the application is running that "memory leak" is there. The second I close my application the memory within 2 seconds is back down to normal as if my program never ran. So the questions have to be asked.
Does Windows 7 clean up memory leaks from bad programs when they are done?
Do all Windows versions do this?
Will Linux and Mac OS X environments do this?
When the program terminates, the operating system reclaims all the memory that had previously been allocated to it. Cleaning up memory leaks may be a perceived by-product of this, but the OS does not actually see it that way. It does not know that the program had been leaking memory, just that it had allocated it.
Once a process in which your application runs exits, the OS reclaims all the memory allocated to the process.
This is typically true for all operating systems not just Windows 7 or Windows for that matter.
Note that, you may observe different behavior for other leaking resources like file handles etc, usually OS'es dont reclaim those. So, it is usually(Yes,there are exceptions) a good practice to make your own application clear the mess(deallocate the allocated resource) that it made instead of delegating it to the OS.
Not only does the program manages memory but does the OS too. And it reclaims all the memory allocated to a program after it exist. It doesn't interfere in between the execution of the program (Other than for paging and swapping). This control over memory of the OS helps the OS from crashing from memory leaks to a point.
Memory management is the act of managing computer memory. The essential requirement of memory management is to provide ways to dynamically allocate portions of memory to programs at their request, and freeing it for reuse when no longer needed. This is critical to the computer system.
BSD Unix normally starts reclaiming memory when the percentage of free memory drops below 5% and continues reclaiming until the free memory percentage reaches 7%
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With