Jemalloc, a widely-used memory allocator, released version 5.4.0 with over 160 commits focused on technical debt reduction, bug fixes, and portability improvements.

A major new feature adds support for pinned memory through the EXTENT_ALLOC_FLAG_PINNED flag, allowing custom extent-allocation hooks to mark non-reclaimable mappings such as HugeTLB pages for preferential reuse outside decay and purge pipelines. According to the release notes, the update includes new mallctl interfaces to report pinned-memory usage and mutex statistics.
The release also allows resuming per-CPU arena selection via thread.arena and improves alignment between human-readable and JSON malloc statistics formats.
A significant incompatible change adapts tcache fill and retention targets per bin based on observed demand between garbage collection events, replacing a fixed refill/flush policy. This removes seven legacy non-experimental controls, though corresponding malloc_conf settings are silently ignored for backward compatibility.
Bug fixes address several issues: errno is now preserved across free operations and page purging, numeric overflow checks in size classes have been fixed, and NULL is now accepted in free_sized() and free_aligned_sized() for C23 correctness. Thread-specific data lifecycle edge cases have been resolved, and a potential deadlock during arena_reset was fixed.
The release includes substantial refactoring to modularize jemalloc’s front end by extracting arena management, initialization, and allocation dispatch from the core. Control dispatch has been simplified, and an OS abstraction layer has been introduced to move platform-dependent operations out of allocator core code.
Portability improvements address compilation on multiple platforms: macOS, MinGW, GCC 16, and others. Changes include fixing malloc_getcpu on macOS, using CLOCK_MONOTONIC for background-thread sleep to prevent clock-rollback stalls, and fixing thread-exit cleanup on MinGW builds.
Key facts
- Over 160 commits focused on refactoring, bug fixes, and test coverage
- New EXTENT_ALLOC_FLAG_PINNED flag enables tracking of non-reclaimable memory mappings like HugeTLB pages
- Seven legacy tcache controls removed; per-bin fill and retention targets now adapt to observed demand
- Introduces OS abstraction layer moving platform-dependent I/O and synchronization operations out of core code
- Fixes address macOS, MinGW, and GCC 16 compilation issues
