Memory
Struct · built-in type
struct MemoryRaw memory (unsafe): allocating and freeing blocks, volatile accesses for hardware registers, and copies of
values for other threads.
Static methods
Section titled “Static methods”| 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. |
Allocate
Section titled “Allocate”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.
VolatileRead
Section titled “VolatileRead”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).
VolatileWrite
Section titled “VolatileWrite”static void VolatileWrite<T>(T* address, T value)Writes value to address with a volatile access: every write reaches the memory, in order.
CopyForThread
Section titled “CopyForThread”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.