namespace
unsafe
namespace unsafe
- ): string;
Cast bytes to a
Stringwithout copying. This is the fastest way to get aStringfrom aUint8ArrayorArrayBuffer.Only use this for ASCII strings. If there are non-ASCII characters, your application may crash or hit confusing bugs such as
"foo" !== "foo".The input buffer must not be garbage collected. Hold a reference to it for the lifetime of the string.
buffer: Uint16Array): string;Cast bytes to a
Stringwithout copying. This is the fastest way to get aStringfrom aUint16ArrayThe input must be a UTF-16 encoded string. This API does no validation whatsoever.
The input buffer must not be garbage collected. Hold a reference to it for the lifetime of the string.
- level?: 0 | 2 | 1): 0 | 1 | 2;
Force the garbage collector to run extremely often, especially inside
bun:test.0: default, disable1: asynchronously call the garbage collector more often2: synchronously call the garbage collector more often.
This is a global setting. It's useful for debugging seemingly random crashes.
BUN_GARBAGE_COLLECTOR_LEVELenvironment variable is also supported.@param levelThe level to set:
0,1, or2@returnsThe previous level
Accurate per-process memory footprint in bytes.
Unlike
process.memoryUsage.rss(), this excludes pages already returned to the OS that the kernel keeps mapped lazily (Darwin'sMADV_FREE_REUSABLE), so leak tests are platform-comparable.Backed by
task_info(TASK_VM_INFO).phys_footprinton Darwin,Pss:from/proc/self/smaps_rollupon Linux, andPrivateUsageon Windows. Returnsundefinedon platforms with no accurate accessor; callers should fall back:Bun.unsafe.memoryFootprint() ?? process.memoryUsage.rss().Dump the mimalloc heap to the console