Buddy Alloc Versions Save

A single header buddy memory allocator for C & C++

v0.4

1 year ago
  • Add functions to reserve and release chunks of memory, which is often required when dealing with non-linear physical memory allocation.

v0.3.2

1 year ago

Allow defragmentation of the arena to happen in realloc.

v0.3.1

2 years ago
  • Fixed some issues with buddy_walk, added more tests for it
  • Added a makefile check for spelling mistakes in the markdown files

v0.3.0

2 years ago
  • Added an additional safety check to buddy_free that prevents freeing when called with a free node leading up to a allocated parent on a different address.
  • Added buddy_safe_free - a safer free function with a size parameter that will not alter the allocator's state if the provided size does not fit the allocated slot size.
  • Added buddy_walk - a callback iterator that walks through all allocated slots which can be used for mailboxes or managed heaps.

v0.2.1

2 years ago

v0.2.1 is a performance-related release

  • Avoid calling highest_bit_position in the hot path by making the tree position a struct and keeping the current depth in it.
  • Switched to alignment-related keywords (and not macros from stdalign.h)
  • Renamed wip/ to bench/ - to clearly indicate its purpose

v0.2.0

2 years ago

v0.2.0 contains changes for better interoperability with different compilers

  • _Bool is replaced with unsigned int to avoid issues between C's _Bool and C++'s bool types
  • Portable implementations for popcount and highest_bit_positions are now used that should work on any compiler

v0.1.5

2 years ago
  • Added buddy_is_empty function

v0.1.4

2 years ago
  • Fixed a few bugs when resizing upwards
  • Minor performance improvements
  • The alignment and minimum allocation size can now be specified by defining BUDDY_ALLOC_ALIGN. This will be made more user-friendly in subsequent releases.
  • Enhanced debugging by adding an invariant check function and making the debug function output to a FILE *.

v0.1.3

2 years ago

Further performance improvements. The values in the tree are now unary encoded and read faster using a popcount builtin.

v0.1.2

2 years ago
  • Numerous performance improvements
  • Fixed two bugs related to downsizing the arena

Debug build performance of buddy_brk.c vs glibc's release malloc on stress-ng.

Note that buddy_brk.c does not return memory to the kernel, so take it with a grain of salt. Still, it is less than twice as slow as glibc now :)

$ env LD_PRELOAD=./buddy_shared.so ~/dev/stress-ng/./stress-ng --malloc 1 --malloc-ops 100000 2>&1
stress-ng: info:  [2896] defaulting to a 86400 second (1 day, 0.00 secs) run per stressor
stress-ng: info:  [2896] dispatching hogs: 1 malloc
stress-ng: info:  [2896] successful run completed in 0.16s
$ env ~/dev/stress-ng/./stress-ng --malloc 1 --malloc-ops 100000 2>&1
stress-ng: info:  [2900] defaulting to a 86400 second (1 day, 0.00 secs) run per stressor
stress-ng: info:  [2900] dispatching hogs: 1 malloc
stress-ng: info:  [2900] successful run completed in 0.11s