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

# hbwallocator(3)

The C++ allocator compatible with the C++ standard library allocator concepts Note: This is EXPERIMENTAL API. The functionality and the header file itself can be changed (including non-backward compatible changes) or removed.

## NAME

hbw::allocator\<T\> - The C++ allocator compatible with the C++ standard library allocator concepts\
 **Note:** This is EXPERIMENTAL API. The functionality and the header file itself can be changed (including non-backward compatible changes) or removed.

## SYNOPSIS

```
#include <hbw_allocator.h>

Link with -lmemkind

hbw::allocator();
template <class U>hbw::allocator<T>::allocator(const hbw::allocator<U>&);
hbw::allocator<T>::~allocator()'
hbw::allocator<T>::pointer hbw::allocator<T>::address(hbw::allocator<T>::reference x);
hbw::allocator<T>::const_pointer hbw::allocator<T>::address(hbw::allocator<T>::const_reference x);
hbw::allocator<T>::pointer hbw::allocator<T>::allocate(hbw::allocator<T>::size_type n, const void * = 0);
void hbw::allocator<T>::deallocate(hbw::allocator<T>::pointer p, hbw::allocator<T>::size_type n);
hbw::allocator<T>::size_type  hbw::allocator<T>::max_size();
void hbw::allocator<T>::construct(hbw::allocator<T>::pointer p, const hbw::allocator<T>::value_type& val);
void hbw::allocator<T>::destroy(hbw::allocator<T>::pointer p);
```

## DESCRIPTION

The **hbw::allocator\<T\>** is intended to be used with STL containers to allocate high bandwidth memory. Memory management is based on hbwmalloc (memkind library), enabling users to gain performance in multithreaded applications. Refer [**hbwmalloc**(3)](/hbwmalloc/3.md) and [**memkind**(3)](/memkind/3.md) man page for more details.

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

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

**Note:**\
 **hbw::allocator\<T\>::pointer hbw::allocator\<T\>::allocate(hbw::allocator\<T\>::size\_type** *n***, const void \* = 0)** allocates high bandwidth memory using **hbw\_malloc**(). Throw *std::bad\_alloc* when:\

*n* = 0,

*n* \> **max\_size**()

or there is not enough memory to satisfy the request.

**hbw::allocator\<T\>::deallocate(hbw::allocator\<T\>::pointer** *p***, hbw::allocator\<T\>::size\_type** *n***)** deallocates memory associated with pointer returned by **allocate**() using **hbw\_free**().

## ERRORS

The same as described in **ERRORS** section of [**hbwmalloc**(3)](/hbwmalloc/3.md) man page.

## NOTES

The **hbw::allocator\<T\>** behavior depends on hbwmalloc heap management policy. To get and set the policy please use **hbw\_get\_policy**() and **hbw\_set\_policy**() respectively.

## COPYRIGHT

Copyright (C) 2015 - 2020 Intel Corporation. All rights reserved.

## SEE ALSO

[**hbwmalloc**(3)](/hbwmalloc/3.md), [**numa**(3)](/numa/3.md), [**numactl**(8)](/numactl/8.md), [**memkind**(3)](/memkind/3.md)
