Allocation wrappers, raw memory operations, cached small-block helpers, and heap-usage queries.
"memory" use exposes raw memory bindings, cached allocation helpers, public allocation entry points, and heap-usage queries.
SYNCHRONIZED reports whether the cached allocation helpers synchronize access to their reusable-block queues.haveSLMemoryMaxCachedSize reports whether SL_MEMORY_MAX_CACHED_SIZE is configured explicitly.SL_MEMORY_MAX_CACHED_SIZE is the greatest allocation size handled by the cached helpers.debugMemory reports whether the public allocation entry points also maintain allocation metrics.debugMemory is FALSE, the public allocation entry points forward to the cached helpers. When debugMemory is TRUE, they also update allocation metrics.(size -- ptr)Allocates one block through the module’s public allocator.
(newSize oldSize ptr -- newPtr)Resizes one block through the module’s public allocator.
min(oldSize newSize).(size ptr --)Releases one block previously handled by the module’s public allocator.
"memory" use
"control" use
{} () {} [
p0: 4nx mplMalloc;
4nx 65 p0 memset drop
p1: 8nx 4nx p0 mplRealloc;
p1 Nat8 addressToReference new 65n8 same printStack _:;
8nx p1 mplFree
] "main" exportFunction
TRUE
"memory" use
"String" use
"control" use
{} Int32 {} [
p0: 4nx mplMalloc;
4nx 65 p0 memset drop
p1: 8nx 4nx p0 mplRealloc;
p1 Nat8 addressToReference new 65n8 same print
LF print
8nx p1 mplFree
0
] "main" exportFunction
TRUE
malloc: allocates size bytes.realloc: resizes one allocation.free: releases one allocation.memcpy: copies one byte range without overlap handling.memmove: copies one byte range with overlap handling.memcmp: compares two byte ranges.memset: fills one byte range with one byte value.(size -- ptr)Allocates memory, reusing cached blocks for sizes not greater than SL_MEMORY_MAX_CACHED_SIZE.
0nx is invalid.(size ptr --)Releases one block previously handled by fastAllocate or fastReallocate.
SL_MEMORY_MAX_CACHED_SIZE return the block to the module cache.size must be nonzero.(newSize oldSize ptr -- newPtr)Allocates one new block of newSize, copies the shared prefix of the old and new ranges, and releases the old block.
min(oldSize newSize).oldSize and newSize must be nonzero.(value -- size)Returns the heap usage attributable to value as Natx.
0nx.Ref-like fields are visited recursively and their heap usage is added.Ref-like are not followed recursively."memory" use
"control" use
{} () {} [
{a: 1i32; b: 2i32;} getHeapUsedSize printStack _:;
] "main" exportFunction
0nx
When debugMemory is TRUE, getMemoryMetrics (-- metrics) returns one record with the current allocation accounting.
memoryCurrentAllocationCount: current live allocation count.memoryTotalAllocationCount: total allocation count since program start.memoryCurrentAllocationSize: current live allocated byte count.memoryTotalAllocationSize: total allocated byte count since program start.memoryMaxAllocationSize: greatest live allocated byte count reached so far.memoryChecksum: checksum over currently live allocation addresses.