-
Notifications
You must be signed in to change notification settings - Fork 0
This builds a minimalistic memory allocator that can be used to manually manage virtual memory. The goal is to have a reliable library that accounts for explicit allocation, reallocation, and initialization of memory.
adumitrescu2708/Memory-Allocator
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
@name Dumitrescu Alexandra @date 11.04.2023 @for Operating Systems - Memory Allocator _________ Contents 1. Memory Allocator List 2. Steps & cases in malloc(), calloc(), realloc() functions 3. Credits 1. | Our list resspects the following rules: | 1.1 The blocks of memory alloced using brk() syscall will be | before the blocks alloced using mmap() in the list. | 1.2 When freeing a mmap() alloced block it will be removed from | the list since it can't be reused. When attempting to free a | brk() alloced block the status of the block will be set to free | and the block will take part in reusing memory. | 1.3 The memory is 8 bytes aligned | 1.4 Each time we request a chunk of contiguous memory, we coalesce | blocks that are freed and search for the best fit. | 1.5 Best fit rule says that we search for the smallest larger | contiguous chunk of freed memory than the requested size. [A] 2. | 2.1 MALLOC() | When attempting to malloc a chunk of memory we first coalesce | adjacent blocks of freed memory, then apply the best fit rule [A] | and if a block is found we try to split it and if not we add | the block: | - at the end of the list using mmap() if | the given size is > MMAP_TRESHOLD | - after all alloced blocks using brk() if | the given size is < MMAP_TRESHOLD | 2.2 CALLOC() | We apply the same idea from malloc, but the memory is | 0 initialised and instead of MMAP_TRESHOLD we use | page_size for deciding wether a block is mapped or alloced | 2.3 REALLOC() | First check wether the block can be extended, either by | coalescing the next free blocks, or by extending the last | free block in the list. If no match is found, then apply | coalescing on the entire list and follow the best fit rule. | If no match is found again, then relocate the block at the end | of the list. | 2.4 For more details, check the comments on each method 3. | 3.1 https://danluu.com/malloc-tutorial/ | 3.2 https://moss.cs.iit.edu/cs351/slides/slides-malloc.pdf
About
This builds a minimalistic memory allocator that can be used to manually manage virtual memory. The goal is to have a reliable library that accounts for explicit allocation, reallocation, and initialization of memory.
Topics
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published