Download Memory Management

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Memory Management
• Memory management is the art and the process of
coordinating and controlling the use of memory in
a computer system
• Why memory management?
–
–
–
–
–
–
Multiple processing
Relocation
Protection
Sharing
Logical Organization
Physical Organization
1
2
Three areas of memory management
• Memory management hardware
– MMUs (Memory Management Unit), RAM,
etc.
• Operating system memory management:
– Virtual memory, protection, etc.
• Application memory management:
– Allocation, garbage collection, etc.
3
Memory Management Hardware
• Memory management devices include
RAM, MMUs, caches, disks, and processor
registers
• Ex. MMU
– a hardware device responsible for handling
memory(2) accesses requested by the main
processor
– translates virtual addresses to physical
addresses
4
Operating System Memory Management
• Virtual Memory
– Operating systems simulates having more memory than is
available as main memory, by storing part of the data in
backing store, typically on disk.
– If the page referenced by the virtual address is not
currently in main memory, a page fault occurs, triggering
an operating system handler that swaps in the page.
– Some other page might be swapped out to make room
– Benefits
5
Operating System Memory Management
• Protection (also known as memory protection, page
protection)
• Operating systems can protect memory pages
against a combination of read, write or execute
accesses by a process.
• A process which attempts a protected access will
trigger a protection fault.
6
Application Memory Management: Allocation
• When the program requests a block of memory, the
memory manager must allocate that blockout of the
larger blocks it has received from the operating
system.
• The part of the memory manager that does this is
known as the allocator.
• Allocation techniques:
– First fit
– Buddy system
– Suballocators
7
Application Memory Management: Recycling
• When memory blocks have been allocated, but the
data they contain is no longer required by the
program, then the blocks can be recycled for
reuse.
• There are two approaches to recycling memory:
– either the programmer must decide when memory
can be reused (known as manual memory
management);
– or the memory manager must be able to work it out
(known as automatic memory management).
8
Application memory manager constraints
• CPU overhead
– The additional time taken by the memory manager
while the program is running
• Interactive pause times
– How much delay an interactive user observes
• Memory overhead
– How much space is wasted for administration, rounding
(known as internal fragmentation), and poor layout
(known as external fragmentation).
9
Memory management problems
•
•
•
•
•
•
Premature free or dangling pointer
Memory leak
External fragmentation
Poor locality of reference
Inflexible design
Interface complexity
10