---
name: "fixedallocator"
section: "3"
platform: "linux"
package: "libmemkind-dev"
version: "1.14.0-2"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/fixedallocator"
---

# fixedallocator(3)

The C++ allocator compatible with the C++ standard library allocator concepts Note: fixed\_allocator.h is a part of stable API (STANDARD API).

## NAME

libmemkind::fixed::allocator\<T\> - The C++ allocator compatible with the C++ standard library allocator concepts\
 **Note:** *fixed\_allocator.h* is a part of stable API (STANDARD API).

## 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

The **libmemkind::fixed::allocator\<T\>** is intended to be used with STL containers to allocate memory on specific area. Memory management is handled by jemalloc on the supplied area. Refer [**memkind**(3)](/memkind/3.md) man page for more details.

All public member types and functions correspond to standard library allocator concepts and definitions. The current implementation supports C++11 standard.

Template arguments:\
 *T* is an object type aliased by value\_type.\
 *U* is an object type.

**Note:**\
 **T \*libmemkind::fixed::allocator\<T\>::allocate(std::size\_t** *n***)** allocates memory using **memkind\_malloc**() on the area supplied to **libmemkind::fixed::allocator**(). Throws *std::bad\_alloc* when:\

*n* = 0

or there is not enough memory to satisfy the request.

**libmemkind::fixed::allocator\<T\>::deallocate(T** *\*p***, std::size\_t** *n***)** deallocates memory associated with pointer returned by **allocate**() using **memkind\_free**().

## COPYRIGHT

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

## SEE ALSO

[**memkind**(3)](/memkind/3.md)
