docs/Writerside/topics/memory.md

Sun, 23 Nov 2025 13:15:19 +0100

author
Mike Becker <universe@uap-core.de>
date
Sun, 23 Nov 2025 13:15:19 +0100
changeset 1508
dfc0ddd9571e
parent 1318
12fa1d37fe48
permissions
-rw-r--r--

optimize sorted insertion by using the infimum instead of the supremum

The reason is that the supremum returns the equal element with the smallest index, and we want the largest.
Therefore, we use the infimum, which already gives us the largest index when there are equal elements, and increase the index by one. The infimum is also guaranteed to exist in that case.

# Memory Management

With the `CxAllocator` interface UCX provides the possibility to use custom allocator functions for different purposes.
Many UCX functions support the use of specialized allocators or provide a second function suffixed with `_a`.

For convenience, functions that are not explicitly requesting an allocator - like e.g. `cx_strdup_a()` - also accept
`NULL` as an allocator, in which case the [default allocator](allocator.h.md#default-allocator) is used.

Additionally, UCX also provides a [memory pool](mempool.h.md) implementation of the allocator interface.

> Although not part of the public API, UCX is also implementing the allocator interface
> in its own test suite: `CxTestingAllocator`. This allocator keeps track of memory allocations
> and deallocations with the goal to detect memory management errors.  

mercurial