copyright © genetic computer school 2008 computer systems architecture sa 7- 0 lesson 7 memory...
TRANSCRIPT
SA 7- 1Copyright © Genetic Computer School 2008
Computer Systems Architecture
Lesson 7
Memory Management
SA 7- 2Copyright © Genetic Computer School 2008
Computer Systems Architecture
LESSON OVERVIEW
areas of memory managementMemory and storage managementMemory management in virtual systemsAddress translation mechanismsMemory management problemsManual memory managementAutomatic memory management
SA 7- 3Copyright © Genetic Computer School 2008
Computer Systems Architecture
Areas Of Memory Management
Memory management is usually divided into three areas:
Hardware
Operating system
Application
SA 7- 4Copyright © Genetic Computer School 2008
Computer Systems Architecture
Hardware Memory Management
Memory management at the hardware
level is concerned with the electronic
devices that actually store data.
This includes things like RAM and
memory caches.
SA 7- 5Copyright © Genetic Computer School 2008
Computer Systems Architecture
Operating System Memory Management
In the operating system, memory must be
allocated to user programs, and reused by
other programs when it is no longer required.
The operating system can pretend that the
computer has more memory than it actually
does, and also that each program has the
machine's memory to itself.
SA 7- 6Copyright © Genetic Computer School 2008
Computer Systems Architecture
Application Memory Management_1
It involves supplying the memory needed for a program's objects and data structures from the limited resources available, and recycling that memory for reuse when it is no longer required. Because application programs cannot in general predict in advance how much memory they are going to require, they need additional code to handle their changing memory requirements.
SA 7- 7Copyright © Genetic Computer School 2008
Computer Systems Architecture
Application Memory Management_2
Application memory
management combines
two related tasks:
Allocation
Recycling
SA 7- 8Copyright © Genetic Computer School 2008
Computer Systems Architecture
Application Memory Manager
CPU overhead
Interactive pause times
Memory overhead
SA 7- 9Copyright © Genetic Computer School 2008
Computer Systems Architecture
Memory In Computer System
Virtual memory
High-speed cache
Main memory
Secondary memory
SA 7- 10Copyright © Genetic Computer School 2008
Computer Systems Architecture
Memory Management In Virtual System
Demand Paging
Fetching
Perfecting
Replacement Strategies
SA 7- 11Copyright © Genetic Computer School 2008
Computer Systems Architecture
Memory Manager
Provides abstraction of a protected address space through translation.
Provides the abstraction of large virtual address spaces, effectively liberating programmers from physical memory constraints.
SA 7- 12Copyright © Genetic Computer School 2008
Computer Systems Architecture
Address Translation Mechanisms_1
Efficiency in sparse address space
Address translation for protection
Generic address translation
Obvious solution
SA 7- 13Copyright © Genetic Computer School 2008
Computer Systems Architecture
Address Translation Mechanisms_2
Paging
Protection
Problems
Advantages
Obvious solution
SA 7- 14Copyright © Genetic Computer School 2008
Computer Systems Architecture
Memory Management ProblemsTypical Problem
Parameter free or dangling pointer
Memory leak
External fragmentation
Poor locality of reference
Inflexible design
Interface complexity
SA 7- 15Copyright © Genetic Computer School 2008
Computer Systems Architecture
Advantages Of Memory Management
It can be easier for the programmer to
understand exactly what is going on;
Some manual memory managers perform
better when there is a shortage of
memory.
SA 7- 16Copyright © Genetic Computer School 2008
Computer Systems Architecture
Disadvantages Of Memory ManagementThe programmer must write a lot of code to
do repetitive bookkeeping of memory;
Memory management must form a
significant part of any module interface;
Manual memory management typically
requires more memory overhead per object;
Memory management bugs are common.
SA 7- 17Copyright © Genetic Computer School 2008
Computer Systems Architecture
Manual Memory Management In Most Implementations
Algol
C
C++
The following languages use mainly manual memory management in most implementations, although many have conservative garbage collection extensions:
COBOL
Fortran
Pascal.
SA 7- 18Copyright © Genetic Computer School 2008
Computer Systems Architecture
Advantages Of Automatic Memory Management
The programmer is freed to work on the actual
problem
Module interfaces are cleaner
There are fewer memory management bugs
Memory management is often more efficient
SA 7- 19Copyright © Genetic Computer School 2008
Computer Systems Architecture
Disadvantages Of Automatic Memory Management
Memory may be retained because it is
reachable, but won't be used again;
Automatic memory managers (currently)
have limited availability.
SA 7- 20Copyright © Genetic Computer School 2008
Computer Systems Architecture
Most Modern Languages Used Mainly In
Automatic Memory ManagementBASIC
DylanTM
Erlang
Haskell
JavaTM
JavaScriptTM
Lisp
ML
Modula-3
Perl
thePostScript® language
Prolog
Python
Scheme
Smalltalk