# O1heap -- constant-complexity real-time memory manager

**URL:** <https://forum.opencyphal.org/t/o1heap-constant-complexity-real-time-memory-manager/738>\
**Category:** General\
**Created:** [January 31, 2020, 3:00pm UTC](https://forum.opencyphal.org/t/o1heap-constant-complexity-real-time-memory-manager/738 "2020-01-31T15:00:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [January 31, 2020, 3:00pm UTC](https://forum.opencyphal.org/t/o1heap-constant-complexity-real-time-memory-manager/738/1 "2020-01-31T15:00:07Z")

</div>

As a part of my ongoing work on updating Libcanard to support UAVCAN v1.0, I implemented a new memory manager that will replace the old fixed-size block allocator. The new manager is located in a separate small repository to enable the use of Libcanard with other allocators if desired.

The advantage of the new allocator is that it can provide arbitrarily-sized memory fragments (as opposed to the fixed-size block allocators used in the old Libcanard and Libuavcan) while having constant time complexity allocation/deallocation routines and well-characterized worst-case memory fragmentation. Variable-size allocation will significantly simplify the library API (especially [when it comes to buffering](https://forum.opencyphal.org/t/canardrxtransfer-payload-reading/600)) and improve the order of time complexity of its internal algorithms.

The library is currently hosted on my private GitHub profile, but it may be moved under the UAVCAN GitHub organization if such is found to be sensible.

> **[GitHub - pavel-kirienko/o1heap: Constant-complexity deterministic memory...](https://github.com/pavel-kirienko/o1heap)**
>
> Constant-complexity deterministic memory allocator (heap) for hard real-time high-integrity embedded systems - GitHub - pavel-kirienko/o1heap: Constant-complexity deterministic memory allocator (he...

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [February 2, 2020, 2:50pm UTC](https://forum.opencyphal.org/t/o1heap-constant-complexity-real-time-memory-manager/738/2 "2020-02-02T14:50:39Z")

</div>

A related article I just posted in Russian:

> **[Динамическая память в системах жёсткого реального времени](https://habr.com/ru/post/486650/)**
>
> Существует класс приложений реального времени, для которых тяжело предсказать потребности в распределении памяти во время выполнения статически. В этот класс входят, например, встраиваемые реализации...
