Skip to main content

Module background

Module background 

Source
Expand description

A thread that returns free memory to the OS on time. Without it, decay runs as the allocator is used, so a process that stops allocating keeps its free pages. It is started explicitly, as in jemalloc, where background threads are off by default: a library that starts threads on its own surprises sandboxes, thread counts and forking programs.

Functionsยง

is_running
Whether the background thread runs in this process
start
Starts the background thread, which ends a decay epoch every 5 seconds in all arenas, so that pages free for 5 to 10 seconds go back to the OS even while the process allocates nothing. Returns whether this call started it; it runs until the process exits.