Skip to content
CShift0.32

Memory

Struct · built-in type

struct Memory

Raw memory (unsafe): allocating and freeing blocks, volatile accesses for hardware registers, and copies of values for other threads.

Name Description
Allocate A new block of size bytes (the C library’s malloc), not cleared.
Free Frees a block from Memory.Allocate.
VolatileRead Reads the value at address with a volatile access: the compiler neither drops nor merges it (hardware registers, memory that something else changes).
VolatileWrite Writes value to address with a volatile access: every write reaches the memory, in order.
CopyForThread A copy of value that shares no reference count with anything else (strings are copied into new blocks), so that another thread can own it.
static void* Allocate(nuint size)

A new block of size bytes (the C library’s malloc), not cleared.

static void Free(void* block)

Frees a block from Memory.Allocate.

static T VolatileRead<T>(T* address)

Reads the value at address with a volatile access: the compiler neither drops nor merges it (hardware registers, memory that something else changes).

static void VolatileWrite<T>(T* address, T value)

Writes value to address with a volatile access: every write reaches the memory, in order.

static T CopyForThread<T>(T value)

A copy of value that shares no reference count with anything else (strings are copied into new blocks), so that another thread can own it. Mutex uses it.