DA5. Memory Leaks¶
Statement¶
Examine memory leaks in different operating systems and identify an OS with the least memory leak. Include a comparison of Linux, Mac, and Windows in your discussion post.
Answer¶
- Memory Leak means forgetting to free memory that is no longer needed. With the program long running, the memory leak will cause the program to use more and more memory until it runs out of memory and crashes.
- Even using Garbage Collection, memory leaks can still occur. This is because the garbage collector sometimes does not know when a variable is no longer needed (e.g. a chunk of memory is still referenced somewhere in the program, despite it is not needed). It is the programmer’s responsibility to free the memory in this case.
- Memory Leaks may not be a problem for short-living processes, since the OS will reclaim the memory when the process is terminated. However, it is a problem for long-living processes; where the process -through out its lifetime- uses more and more memory until it runs out of memory and crashes.
- Long running programs include servers, daemons, background processes, db management systems, and Operating Systems themselves.
- It is difficult to determine which OS has the least memory leak, since it depends on the program that is running and many other factors. Also, all major Oses have strong techniques to prevent memory leaks, manage memory, and they are constantly improving.
- Linux, and Mac OS X are Unix-like operating systems, and they are very similar in terms of memory management. However, Windows is a bit different and more complex.
- The Unix Kernel is known to be robust and lightweight, which may improve memory management.
References¶
- Arpaci-Dusseau, R. H., & Arpaci-Dusseau, A. C. (2018). Operating systems: three easy pieces (1.01 ed.). Arpaci-Dusseau Books. Retrieved June 16, 2022, from https://pages.cs.wisc.edu/~remzi/OSTEP/