Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

immer::gc_heap Class Reference

#include <gc_heap.hpp>

Static Public Member Functions

static void * allocate (std::size_t n)
 
static void * allocate (std::size_t n, norefs_tag)
 
static void deallocate (std::size_t, void *data)
 
static void deallocate (std::size_t, void *data, norefs_tag)
 

Detailed Description

Heap that uses a tracing garbage collector.

This heap uses the Boehm's conservative garbage collector_ under the hood. This is a tracing garbage collector that automatically reclaims unused memory. Thus, it is not needed to call deallocate() in order to release memory.

.. admonition:: Dependencies :class: tip

In order to use this header file, you need to make sure that Boehm's libgc is your include path and link to its binary library.

.. caution:: Memory that is allocated with the standard malloc and free is not visible to libgc when it is looking for references. This means that if, let's say, you store a :cpp:class:immer::vector using a gc_heap inside a std::vector that uses a standard allocator, the memory of the former might be released automatically at unexpected times causing crashes.

.. caution:: When using a gc_heap in combination with immutable containers, the destructors of the contained objects will never be called. It is ok to store containers inside containers as long as all of them use a gc_heap consistently, but storing other kinds of objects with relevant destructors (e.g. containers with reference counting or other kinds of resource handles) might cause memory leaks and other problems.

.. _boehm's conservative garbage collector: https://github.com/ivmai/bdwgc

Definition at line 98 of file gc_heap.hpp.

Member Function Documentation

◆ allocate() [1/2]

static void* immer::gc_heap::allocate ( std::size_t  n)
inlinestatic

Definition at line 101 of file gc_heap.hpp.

References IMMER_GC_INIT_GUARD_, and IMMER_UNLIKELY.

◆ allocate() [2/2]

static void* immer::gc_heap::allocate ( std::size_t  n,
norefs_tag   
)
inlinestatic

Definition at line 110 of file gc_heap.hpp.

References IMMER_GC_INIT_GUARD_, and IMMER_UNLIKELY.

◆ deallocate() [1/2]

static void immer::gc_heap::deallocate ( std::size_t  ,
void *  data 
)
inlinestatic

Definition at line 119 of file gc_heap.hpp.

◆ deallocate() [2/2]

static void immer::gc_heap::deallocate ( std::size_t  ,
void *  data,
norefs_tag   
)
inlinestatic

Definition at line 124 of file gc_heap.hpp.


The documentation for this class was generated from the following file:
Released under the MIT license