FIXEDALLOCATOR(3)

πŸ“¦ version 1.14.0, in debian bookworm, fedora 43, ubuntu jammy, ubuntu noble

πŸ’– NAME πŸ’–

libmemkind::fixed::allocator<T> β€” bestie, this is the C++ allocator that plays nice with all the C++ standard library allocator concepts 🫢

ok so quick note before we start: fixed_allocator.h is part of the stable API (STANDARD API) ✨ so you can build on it without the vibes getting weird.

🌸 SYNOPSIS 🌸

#include <fixed_allocator.h>

Link with -lmemkind πŸ’…

libmemkind::fixed::allocator(void *addr, size_t size);
template <typename U> libmemkind::fixed::allocator<T>::allocator(const libmemkind::fixed::allocator<U>&) noexcept;
template <typename U> libmemkind::fixed::allocator<T>::allocator(allocator<U>&& other) noexcept;
libmemkind::fixed::allocator<T>::~allocator();
T *libmemkind::fixed::allocator<T>::allocate(std::size_t n) const;
void libmemkind::fixed::allocator<T>::deallocate(T *p, std::size_t n) const;
template <class U, class... Args> void libmemkind::fixed::allocator<T>::construct(U *p, Args... &&args) const;
void libmemkind::fixed::allocator<T>::destroy(T *p) const;

πŸ¦‹ DESCRIPTION πŸ¦‹

So like. libmemkind::fixed::allocator<T> is the one you pair with your STL containers when you want your memory to live on a specific area you picked out yourself πŸ’… The actual memory management? Handled by jemalloc, but only on the area you supplied. For the full lore, go read the memkind(3) man page, iykyk.

Every public member type and function lines up with the standard library allocator concepts and definitions β€” no rogue behaviour, no surprises, periodt. The current implementation supports the C++11 standard. πŸ”₯

🌈 Template arguments 🌈

  • T β€” an object type aliased by value_type ✨
  • U β€” an object type πŸ’œ

πŸŽ€ Note πŸŽ€

T *libmemkind::fixed::allocator<T>::allocate(std::size_t n) allocates memory using memkind_malloc() on the area that was supplied to libmemkind::fixed::allocator(). It throws std::bad_alloc when:

  • n = 0
  • or there is not enough memory to satisfy the request 😭

And libmemkind::fixed::allocator<T>::deallocate(T *p, std::size_t n) deallocates the memory associated with a pointer returned by allocate(), using memkind_free(). Clean up after yourself bestie 🧚


Copyright (C) 2021 Intel Corporation. All rights reserved.


⭐ SEE ALSO ⭐


ok that's the whole page, mwah πŸ’– brought to you by Intel Corporation, dated 2021-12-03, filed under FIXEDALLOCATOR(3) β€” go forth and allocate responsibly, bestie πŸŽ€βœ¨

πŸ“¦ where this page comes from