Presentation is loading. Please wait.

Presentation is loading. Please wait.

Memory Management. Memory  Commemoration or Remembrance.

Similar presentations


Presentation on theme: "Memory Management. Memory  Commemoration or Remembrance."— Presentation transcript:

1 Memory Management

2 Memory  Commemoration or Remembrance

3 Management  the technique, practice or science of managing.

4 Memory Management  Commemoration Technique

5 The Memory Management Memory management is a complex field of computer science and there are many techniques being developed to make it more efficient. This guide is designed to introduce you to some of the basic memory management issues that programmers face.

6 Memory management is usually divided into three areas: Hardware, Operating System, and application, although the distinctions are a little fuzzy. In most computer systems, all three are present to some extent, forming layers between the user's program and the actual memory hardware. The Memory Management Reference is mostly concerned with application memory management.

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

8 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; both of these are features of virtual memory systems.

9 Application memory management Application memory management 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.

10 Application memory management combines two related tasks Allocation When the program requests a block of memory, the memory manager must allocate that block out 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.

11 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). These are both described in more detail below.

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

13 Memory management problems The basic problem in managing memory is knowing when to keep the data it contains, and when to throw it away so that the memory can be reused.

14 Premature free or dangling pointer Many programs give up memory, but attempt to access it later and crash or behave randomly. Memory leak Some programs continually allocate memory without ever giving it up and eventually run out of memory. This condition is known as a memory leak.

15 External fragmentation A poor allocator can do its job of giving out and receiving blocks of memory so badly that it can no longer give out big enough blocks despite having enough spare memory.

16 Poor locality of reference Another problem with the layout of allocated blocks comes from the way that modern hardware and operating system memory managers handle memory: successive memory accesses are faster if they are to nearby memory locations.

17 Inflexible design These problems occur because any memory management solution tends to make assumptions about the way in which the program is going to use memory, such as typical block sizes, reference patterns, or lifetimes of objects.

18 Interface complexity If objects are passed between modules, then the interface design must consider the management of their memory.

19 Automatic memory management Automatic memory management is a service, either as a part of the language or as an extension, that automatically recycles memory that a program would not otherwise use again.

20 The advantages of automatic memory management are:  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.

21 The disadvantages of automatic memory management are:  Memory may be retained because it is reachable, but won't be used again;  Automatic memory managers (currently) have limited availability.


Download ppt "Memory Management. Memory  Commemoration or Remembrance."

Similar presentations


Ads by Google