diff --git a/docs/gfx/Buddy_allocator.png b/docs/gfx/Buddy_allocator.png new file mode 100644 index 0000000..507314d Binary files /dev/null and b/docs/gfx/Buddy_allocator.png differ diff --git a/docs/html/custom_memory_pools.html b/docs/html/custom_memory_pools.html index 89132d1..be4cce0 100644 --- a/docs/html/custom_memory_pools.html +++ b/docs/html/custom_memory_pools.html @@ -141,7 +141,23 @@ Ring buffer
Ring buffer with lost allocations
-

Ring buffer is available only in pools with one memory block - VmaPoolCreateInfo::maxBlockCount must be 1. Otherwise behavior is undefined.

+

Ring buffer is available only in pools with one memory block - VmaPoolCreateInfo::maxBlockCount must be 1. Otherwise behavior is undefined.

+

+Buddy allocation algorithm

+

There is another allocation algorithm that can be used with custom pools, called "buddy". Its internal data structure is based on a tree of blocks, each having size that is a power of two and a half of its parent's size. When you want to allocate memory of certain size, a free node in the tree is located. If it's too large, it is recursively split into two halves (called "buddies"). However, if requested allocation size is not a power of two, the size of a tree node is aligned up to the nearest power of two and the remaining space is wasted. When two buddy nodes become free, they are merged back into one larger node.

+
+Buddy allocator +
+

The advantage of buddy allocation algorithm over default algorithm is faster allocation and deallocation, as well as smaller external fragmentation. The disadvantage is more wasted space (internal fragmentation).

+

For more information, please read "Buddy memory allocation" on Wikipedia or other sources that describe this concept in general.

+

To use buddy allocation algorithm with a custom pool, add flag VMA_POOL_CREATE_BUDDY_ALGORITHM_BIT to VmaPoolCreateInfo::flags while creating VmaPool object.

+

Several limitations apply to pools that use buddy algorithm:

+