Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Memory Allocator

A custom memory allocation library implemented in C++ .

Overview

Implemented malloc(), free(), calloc() and realloc() from scratch using Linux system calls (sbrk, mmap).

Parts

Part 1 — Naive Malloc

  • Basic memory allocation using sbrk()

Part 2 — Basic Malloc

  • Metadata structs attached to each allocation
  • Free block reuse with linked list
  • Implemented: smalloc, sfree, scalloc, srealloc

Part 3 — Buddy Allocator

  • Buddy memory allocation system
  • Blocks always sized as powers of 2
  • Block splitting on allocation
  • Block merging on free
  • mmap() for large allocations (128KB+)

Functions

  • smalloc — allocate memory
  • sfree — free memory
  • scalloc — allocate zeroed memory
  • srealloc — reallocate memory

Tech

C++ · sbrk · mmap · Virtual Memory · Buddy Allocator · Memory Management

About

Custom malloc/free/calloc/realloc in C++, including a buddy allocator. Uses sbrk and mmap under the hood.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages