memory.h

Include dependency graph for memory.h:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "2" [label="erl_nif.h" tooltip="erl_nif.h"]
    "1" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/memory.h" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/memory.h" fillcolor="#BFBFBF"]
    "3" [label="term_typedef.h" tooltip="term_typedef.h"]
    "7" [label="utils.h" tooltip="utils.h"]
    "5" [label="inttypes.h" tooltip="inttypes.h"]
    "4" [label="limits.h" tooltip="limits.h"]
    "8" [label="stddef.h" tooltip="stddef.h"]
    "6" [label="stdint.h" tooltip="stdint.h"]
    "9" [label="stdlib.h" tooltip="stdlib.h"]
    "2" -> "3" [dir=forward tooltip="include"]
    "1" -> "2" [dir=forward tooltip="include"]
    "1" -> "3" [dir=forward tooltip="include"]
    "1" -> "7" [dir=forward tooltip="include"]
    "1" -> "6" [dir=forward tooltip="include"]
    "1" -> "9" [dir=forward tooltip="include"]
    "3" -> "4" [dir=forward tooltip="include"]
    "3" -> "5" [dir=forward tooltip="include"]
    "3" -> "6" [dir=forward tooltip="include"]
    "7" -> "8" [dir=forward tooltip="include"]
}

This graph shows which files directly or indirectly include memory.h:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "42" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/avmpack.c" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/avmpack.c"]
    "41" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/avmpack.h" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/avmpack.h"]
    "21" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/bif.c" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/bif.c"]
    "20" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/bif.h" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/bif.h"]
    "15" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/bitstring.c" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/bitstring.c"]
    "14" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/bitstring.h" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/bitstring.h"]
    "3" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/context.c" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/context.c"]
    "19" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/context.h" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/context.h"]
    "23" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/debug.c" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/debug.c"]
    "22" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/debug.h" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/debug.h"]
    "44" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/defaultatoms.c" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/defaultatoms.c"]
    "43" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/defaultatoms.h" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/defaultatoms.h"]
    "35" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/dictionary.c" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/dictionary.c"]
    "36" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/dictionary.h" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/dictionary.h"]
    "2" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/erl_nif_priv.h" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/erl_nif_priv.h"]
    "37" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/exportedfunction.h" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/exportedfunction.h"]
    "25" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/externalterm.c" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/externalterm.c"]
    "39" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/externalterm.h" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/externalterm.h"]
    "4" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/globalcontext.c" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/globalcontext.c"]
    "40" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/globalcontext.h" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/globalcontext.h"]
    "16" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/interop.c" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/interop.c"]
    "26" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/interop.h" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/interop.h"]
    "9" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/mailbox.c" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/mailbox.c"]
    "5" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/memory.c" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/memory.c"]
    "1" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/memory.h" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/memory.h" fillcolor="#BFBFBF"]
    "18" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/module.c" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/module.c"]
    "28" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/module.h" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/module.h"]
    "11" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/nifs.c" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/nifs.c"]
    "33" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/nifs.h" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/nifs.h"]
    "17" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/opcodesswitch.h" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/opcodesswitch.h"]
    "45" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/overflow_helpers.h" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/overflow_helpers.h"]
    "29" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/platform_nifs.h" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/platform_nifs.h"]
    "12" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/port.c" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/port.c"]
    "10" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/port.h" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/port.h"]
    "6" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/posix_nifs.c" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/posix_nifs.c"]
    "38" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/posix_nifs.h" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/posix_nifs.h"]
    "7" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/refc_binary.c" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/refc_binary.c"]
    "8" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/resources.c" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/resources.c"]
    "24" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/scheduler.c" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/scheduler.c"]
    "34" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/scheduler.h" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/scheduler.h"]
    "31" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/stacktrace.c" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/stacktrace.c"]
    "30" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/stacktrace.h" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/stacktrace.h"]
    "32" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/sys.h" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/sys.h"]
    "27" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/term.c" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/term.c"]
    "13" [label="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/term.h" tooltip="/home/winford/github/UncleGrumpy/AtomVM/src/libAtomVM/term.h"]
    "41" -> "42" [dir=back tooltip="include"]
    "41" -> "4" [dir=back tooltip="include"]
    "41" -> "11" [dir=back tooltip="include"]
    "20" -> "21" [dir=back tooltip="include"]
    "20" -> "18" [dir=back tooltip="include"]
    "20" -> "11" [dir=back tooltip="include"]
    "20" -> "17" [dir=back tooltip="include"]
    "14" -> "15" [dir=back tooltip="include"]
    "14" -> "16" [dir=back tooltip="include"]
    "14" -> "17" [dir=back tooltip="include"]
    "19" -> "20" [dir=back tooltip="include"]
    "19" -> "3" [dir=back tooltip="include"]
    "19" -> "22" [dir=back tooltip="include"]
    "19" -> "2" [dir=back tooltip="include"]
    "19" -> "25" [dir=back tooltip="include"]
    "19" -> "4" [dir=back tooltip="include"]
    "19" -> "26" [dir=back tooltip="include"]
    "19" -> "5" [dir=back tooltip="include"]
    "19" -> "18" [dir=back tooltip="include"]
    "19" -> "28" [dir=back tooltip="include"]
    "19" -> "11" [dir=back tooltip="include"]
    "19" -> "33" [dir=back tooltip="include"]
    "19" -> "12" [dir=back tooltip="include"]
    "19" -> "10" [dir=back tooltip="include"]
    "19" -> "7" [dir=back tooltip="include"]
    "19" -> "8" [dir=back tooltip="include"]
    "19" -> "34" [dir=back tooltip="include"]
    "19" -> "30" [dir=back tooltip="include"]
    "19" -> "27" [dir=back tooltip="include"]
    "22" -> "23" [dir=back tooltip="include"]
    "22" -> "5" [dir=back tooltip="include"]
    "22" -> "17" [dir=back tooltip="include"]
    "22" -> "24" [dir=back tooltip="include"]
    "43" -> "21" [dir=back tooltip="include"]
    "43" -> "44" [dir=back tooltip="include"]
    "43" -> "35" [dir=back tooltip="include"]
    "43" -> "4" [dir=back tooltip="include"]
    "43" -> "16" [dir=back tooltip="include"]
    "43" -> "11" [dir=back tooltip="include"]
    "43" -> "17" [dir=back tooltip="include"]
    "43" -> "12" [dir=back tooltip="include"]
    "43" -> "10" [dir=back tooltip="include"]
    "43" -> "6" [dir=back tooltip="include"]
    "43" -> "8" [dir=back tooltip="include"]
    "43" -> "31" [dir=back tooltip="include"]
    "36" -> "21" [dir=back tooltip="include"]
    "36" -> "3" [dir=back tooltip="include"]
    "36" -> "35" [dir=back tooltip="include"]
    "36" -> "5" [dir=back tooltip="include"]
    "36" -> "11" [dir=back tooltip="include"]
    "36" -> "7" [dir=back tooltip="include"]
    "2" -> "3" [dir=back tooltip="include"]
    "2" -> "4" [dir=back tooltip="include"]
    "2" -> "5" [dir=back tooltip="include"]
    "2" -> "6" [dir=back tooltip="include"]
    "2" -> "7" [dir=back tooltip="include"]
    "2" -> "8" [dir=back tooltip="include"]
    "37" -> "20" [dir=back tooltip="include"]
    "37" -> "28" [dir=back tooltip="include"]
    "37" -> "33" [dir=back tooltip="include"]
    "37" -> "17" [dir=back tooltip="include"]
    "37" -> "29" [dir=back tooltip="include"]
    "37" -> "38" [dir=back tooltip="include"]
    "39" -> "25" [dir=back tooltip="include"]
    "39" -> "18" [dir=back tooltip="include"]
    "39" -> "11" [dir=back tooltip="include"]
    "40" -> "41" [dir=back tooltip="include"]
    "40" -> "3" [dir=back tooltip="include"]
    "40" -> "19" [dir=back tooltip="include"]
    "40" -> "43" [dir=back tooltip="include"]
    "40" -> "4" [dir=back tooltip="include"]
    "40" -> "18" [dir=back tooltip="include"]
    "40" -> "28" [dir=back tooltip="include"]
    "40" -> "12" [dir=back tooltip="include"]
    "40" -> "10" [dir=back tooltip="include"]
    "40" -> "6" [dir=back tooltip="include"]
    "40" -> "38" [dir=back tooltip="include"]
    "40" -> "34" [dir=back tooltip="include"]
    "40" -> "32" [dir=back tooltip="include"]
    "26" -> "16" [dir=back tooltip="include"]
    "26" -> "11" [dir=back tooltip="include"]
    "26" -> "6" [dir=back tooltip="include"]
    "26" -> "27" [dir=back tooltip="include"]
    "1" -> "2" [dir=back tooltip="include"]
    "1" -> "9" [dir=back tooltip="include"]
    "1" -> "5" [dir=back tooltip="include"]
    "1" -> "10" [dir=back tooltip="include"]
    "1" -> "7" [dir=back tooltip="include"]
    "1" -> "13" [dir=back tooltip="include"]
    "28" -> "20" [dir=back tooltip="include"]
    "28" -> "18" [dir=back tooltip="include"]
    "28" -> "11" [dir=back tooltip="include"]
    "28" -> "17" [dir=back tooltip="include"]
    "28" -> "29" [dir=back tooltip="include"]
    "28" -> "30" [dir=back tooltip="include"]
    "28" -> "32" [dir=back tooltip="include"]
    "33" -> "18" [dir=back tooltip="include"]
    "33" -> "11" [dir=back tooltip="include"]
    "33" -> "17" [dir=back tooltip="include"]
    "33" -> "6" [dir=back tooltip="include"]
    "17" -> "3" [dir=back tooltip="include"]
    "17" -> "18" [dir=back tooltip="include"]
    "45" -> "21" [dir=back tooltip="include"]
    "29" -> "11" [dir=back tooltip="include"]
    "10" -> "11" [dir=back tooltip="include"]
    "10" -> "12" [dir=back tooltip="include"]
    "38" -> "4" [dir=back tooltip="include"]
    "38" -> "11" [dir=back tooltip="include"]
    "38" -> "6" [dir=back tooltip="include"]
    "34" -> "9" [dir=back tooltip="include"]
    "34" -> "11" [dir=back tooltip="include"]
    "34" -> "17" [dir=back tooltip="include"]
    "34" -> "24" [dir=back tooltip="include"]
    "30" -> "17" [dir=back tooltip="include"]
    "30" -> "31" [dir=back tooltip="include"]
    "32" -> "3" [dir=back tooltip="include"]
    "32" -> "4" [dir=back tooltip="include"]
    "32" -> "18" [dir=back tooltip="include"]
    "32" -> "11" [dir=back tooltip="include"]
    "32" -> "8" [dir=back tooltip="include"]
    "32" -> "24" [dir=back tooltip="include"]
    "13" -> "14" [dir=back tooltip="include"]
    "13" -> "19" [dir=back tooltip="include"]
    "13" -> "35" [dir=back tooltip="include"]
    "13" -> "36" [dir=back tooltip="include"]
    "13" -> "37" [dir=back tooltip="include"]
    "13" -> "39" [dir=back tooltip="include"]
    "13" -> "40" [dir=back tooltip="include"]
    "13" -> "16" [dir=back tooltip="include"]
    "13" -> "26" [dir=back tooltip="include"]
    "13" -> "5" [dir=back tooltip="include"]
    "13" -> "18" [dir=back tooltip="include"]
    "13" -> "28" [dir=back tooltip="include"]
    "13" -> "11" [dir=back tooltip="include"]
    "13" -> "45" [dir=back tooltip="include"]
    "13" -> "10" [dir=back tooltip="include"]
    "13" -> "38" [dir=back tooltip="include"]
    "13" -> "30" [dir=back tooltip="include"]
    "13" -> "27" [dir=back tooltip="include"]
}

Defines

HEAP_NEED_GC_SHRINK_THRESHOLD_COEFF
MIN_FREE_SPACE_SIZE
TYPEDEF_CONTEXT
TYPEDEF_GLOBALCONTEXT
TYPEDEF_HEAP
BEGIN_WITH_STACK_HEAP(size, name)
END_WITH_STACK_HEAP(name, global)
STORAGE_MSO_LIST_INDEX
STORAGE_HEAP_START_INDEX

Typedefs

typedef struct Context Context
typedef struct GlobalContext GlobalContext
typedef struct HeapFragment HeapFragment
typedef struct Heap Heap

Enums

enum MemoryGCResult

Values:

enumerator MEMORY_GC_OK
enumerator MEMORY_GC_ERROR_FAILED_ALLOCATION
enumerator MEMORY_GC_DENIED_ALLOCATION
enum MemoryAllocMode

Values:

enumerator MEMORY_NO_SHRINK
enumerator MEMORY_CAN_SHRINK
enumerator MEMORY_FORCE_SHRINK
enumerator MEMORY_NO_GC

Functions

void memory_init_heap_root_fragment(Heap *heap, HeapFragment *root, size_t size)
enum MemoryGCResult memory_init_heap (Heap *heap, size_t size) MUST_CHECK
static inline size_t memory_heap_fragment_memory_size(const HeapFragment *fragment)
static inline size_t memory_heap_memory_size(const Heap *heap)
static inline MALLOC_LIKE term * memory_heap_alloc (Heap *heap, size_t size)
term memory_copy_term_tree(Heap *new_heap, term t)
enum MemoryGCResult memory_ensure_free_with_roots (Context *ctx, size_t size, size_t num_roots, term *roots, enum MemoryAllocMode alloc_mode) MUST_CHECK
static inline MUST_CHECK enum MemoryGCResult memory_ensure_free_opt (Context *ctx, size_t size, enum MemoryAllocMode alloc_mode)
static inline MUST_CHECK enum MemoryGCResult memory_ensure_free (Context *ctx, size_t size)
MUST_CHECK enum MemoryGCResult memory_erl_nif_env_ensure_free (ErlNifEnv *env, size_t size)
term memory_copy_term_tree_to_storage(term *storage, term **heap_end, term t)
unsigned long memory_estimate_usage(term t)
void memory_heap_append_fragment(Heap *heap, HeapFragment *fragment, term mso_list)
static inline void memory_heap_append_heap(Heap *target, Heap *source)
void memory_sweep_mso_list(term mso_list, GlobalContext *global)
static inline void memory_destroy_heap_fragment(HeapFragment *fragment)
static inline void memory_destroy_heap(Heap *heap, GlobalContext *global)
struct HeapFragment

Collaboration diagram for HeapFragment:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "1" [label="HeapFragment" tooltip="HeapFragment" fillcolor="#BFBFBF"]
    "1" -> "1" [dir=forward tooltip="usage"]
}

Public Members

HeapFragment *next
term mso_list
term *heap_end
union HeapFragment
term storage[]
struct Heap

Collaboration diagram for Heap:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "1" [label="Heap" tooltip="Heap" fillcolor="#BFBFBF"]
    "2" [label="HeapFragment" tooltip="HeapFragment"]
    "1" -> "2" [dir=forward tooltip="usage"]
    "2" -> "2" [dir=forward tooltip="usage"]
}

Public Members

HeapFragment *root
term *heap_start
term *heap_ptr
term *heap_end