Presentation is loading. Please wait.

Presentation is loading. Please wait.

Presentation made by Steponas Šipaila

Similar presentations


Presentation on theme: "Presentation made by Steponas Šipaila"— Presentation transcript:

1 Presentation made by Steponas Šipaila
Memory management Presentation made by Steponas Šipaila

2 What is memory management?
is a form of resource management applied to computer memory. The essential requirement of memory management is to provide ways to dynamically allocate portions of memory to programs at their request, and free it for reuse when no longer needed. Memory management resides in hardware, in the OS and in applications.

3 Memory management in hardware
In hardware, memory management involves components that physically store data, such as RAM(random access memory) chips, memory caches, and flash- based SSDs (solid-state drives).

4 Memory management in hardware and the operating system
In the OS, memory management involves the allocation and constant reallocation of specific memory blocks to individual programs as user demands change.

5 Memory management at the application level
At the application level, memory management ensures the availability of adequate memory for the objects and data structures of each running program at all times.  Application-level memory management is usually categorized as: Automatic memory management Manual memory management

6 Dynamic memory allocation
The task of fulfilling an allocation request consists of locating a block of unused memory of sufficient size.

7 External fragmentation arises when there are many small gaps between allocated memory blocks, which invalidates their use for an allocation request.

8 The allocator’s metadata can also inflate the size of individually small allocations. This is often managed by chunking. Chunking refers to strategies for improving performance by using special knowledge of a situation to aggregate related memory-allocation requests. The memory management system must track outstanding allocations to ensure that they do not overlap and that no memory is ever "lost"

9 Implementations Since the precise location of the allocation is not known in advance, the memory is accessed indirectly, usually through a pointer reference. The specific algorithm used to organize the memory area and allocate and deallocate chunks is interlinked with the kernel, and may use any of the following methods: Fixed-size blocks allocation Buddy blocks Slab allocation Garbage collection

10 Fixed-size blocks allocation
Fixed-size blocks allocation uses a free list of fixed-size blocks of memory (often all of the same size). Works well for simple systems where no large objects need to be allocated. Due to the significantly reduced overhead this method can substantially improve performance for objects that need frequent allocation / de-allocation and is often used in video games.

11 Buddy blocks Memory is allocated into several pools of memory instead of just one, where each pool represents blocks of memory of a certain power of two in size, or blocks of some other convenient size progression.

12 All blocks of a particular size are kept in a sorted linked list or tree and all new blocks that are formed during allocation are added to their respective memory pools for later use. If a smaller size is requested than is available, the smallest available size is selected and split.

13 One of the resulting parts is selected, and the process repeats until the request is complete.
When a block is allocated, the allocator will start with the smallest sufficiently large block to avoid needlessly breaking blocks. When a block is freed, it is compared to its buddy. If they are both free, they are combined and placed in the correspondingly larger-sized buddy-block list.

14 However, there still exists the problem of memory being wasted because the memory requested is a little larger than a small block, but a lot smaller than a large block. 

15 Slab allocation This memory allocation mechanism pre-allocates memory chunks suitable to fit objects of a certain type or size. These chunks are called caches and the allocator only has to keep track of a list of free cache slots. Constructing an object will use the any one of the free cache slots and destructing an object will add a slot back to the free cache slot list. This technique alleviates memory fragmentation and is efficient as there is no need to search for a suitable portion of memory, as any open slot will suffice.

16 Garbage collection Garbage collection is a strategy for automatically detecting memory allocated to objects that are no longer usable in a program, and returning that allocated memory to a pool of free memory locations. This method is in contrast to "manual" memory management. Reduces programmer workload but in return requires memory resources of its own

17 Thank you for your attention!


Download ppt "Presentation made by Steponas Šipaila"

Similar presentations


Ads by Google