Skip to main content

set_pool_retention

Function set_pool_retention 

Source
pub fn set_pool_retention(states_per_thread: usize)
Expand description

Set how many inflate states each thread keeps parked between uses.

Every inflate on a thread first checks its pool and, finding it empty, builds a fresh state: one allocation of roughly 47.5 KB (zlib-rs allocates the state and its 32 KB window together). The default of one keeps that allocation resident on every thread that ever inflated anything, which is what a host with memory to spare wants. A client whose whole heap is a few hundred KB may prefer 0: every inflate then pays the allocation and releases it, so the ~47.5 KB is only ever held while something is actually being inflated, at the cost of one large malloc per compressed frame.

Process-wide; takes effect on the next park. Lowering it does not evict states already parked, see drain_pool.