gcAggressionLevel

Bun

Symbol

Unsafe.gcAggressionLevel

gcAggressionLevel(level?: 0 | 2 | 1): 0 | 1 | 2

Force the garbage collector to run extremely often, especially inside bun:test.

  • 0: default, disable
  • 1: asynchronously call the garbage collector more often
  • 2: synchronously call the garbage collector more often.

This is a global setting. It's useful for debugging seemingly random crashes.

BUN_GARBAGE_COLLECTOR_LEVEL environment variable is also supported.

@returns

The previous level