Memory Management Fundamentals
Memory management refers to controlling and coordinating a computer’s memory. Using proper memory management techniques, we can ensure that memory blocks are appropriately allocated across different processes and applications running in the operating system (OS).
An OS facilitates the interaction between applications and a computer’s hardware, enabling software applications to interface with a computer’s hardware and overseeing the management of a system’s hardware and software resources.
OSs orchestrate how memory is allocated across several processes and how space is moved between the main memory and the device’s disk during executions. The memory comprises blocks that are tracked during usage and freed after processes complete their operation.
While you may not need to understand all the inner workings of an OS and how it interacts with applications and hardware, it is essential to know how to write applications that make the best use of the facilities that OSs make available to us, so that we can author efficient applications.
In this chapter, we will explore the inner concepts of memory management and begin to explore, at a high level, the following topics:
- The fundamentals of memory management
- How garbage collection works
- The pros and cons of memory management
- The effects of memory management on application performance
By the end of this chapter, you should better appreciate the thought process that goes into ensuring that applications make the best use of memory, and you will understand the moving parts of memory allocation and deallocation.
Let’s begin with an overview of how memory management works.