10
Memory Management COSC 513 Presentation Jun Tian 08/17/2000

Memory Management COSC 513 Presentation Jun Tian 08/17/2000

Embed Size (px)

Citation preview

Page 1: Memory Management COSC 513 Presentation Jun Tian 08/17/2000

Memory Management

COSC 513 Presentation

Jun Tian

08/17/2000

Page 2: Memory Management COSC 513 Presentation Jun Tian 08/17/2000

2

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

Page 3: Memory Management COSC 513 Presentation Jun Tian 08/17/2000

3

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.

Page 4: Memory Management COSC 513 Presentation Jun Tian 08/17/2000

4

Memory Management Hardware

• Memory management devices include RAM, MMUs, caches, disks, and processor registers

• Ex. MMU– a hardware device responsible for handling

memory accesses requested by the main processor

– translates virtual addresses to physical addresses

Page 5: Memory Management COSC 513 Presentation Jun Tian 08/17/2000

5

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

Page 6: Memory Management COSC 513 Presentation Jun Tian 08/17/2000

6

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.

Page 7: Memory Management COSC 513 Presentation Jun Tian 08/17/2000

7

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

Page 8: Memory Management COSC 513 Presentation Jun Tian 08/17/2000

8

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).

Page 9: Memory Management COSC 513 Presentation Jun Tian 08/17/2000

9

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).

Page 10: Memory Management COSC 513 Presentation Jun Tian 08/17/2000

10

Memory management problems

• Premature free or dangling pointer

• Memory leak

• External fragmentation

• Poor locality of reference

• Inflexible design

• Interface complexity