Master the fundamental concepts of memory optimization through this focused micro-challenge.
Facebook's jemalloc and Google's tcmalloc partition thread caches and size classes to cut lock contention and improve locality. Firefox, Redis, and FreeBSD default to jemalloc for server workloads. Swapping allocators is often a one-line LD_PRELOAD experiment.
Many small allocations across threads: tcmalloc shines. Fragmentation-heavy long-running daemons: jemalloc's arena tuning helps. Always measure your allocation profile.
bashLoading…
malloc_stats or jemalloc prof before trusting preload.soKeep the relevant documentation open while you implement. When your output disagrees with the reference, trace one failing case by hand before changing random lines.
You will compare default malloc versus jemalloc or tcmalloc on a provided allocation-heavy benchmark. This exercise requires reporting throughput and explaining which size class behavior mattered.
Compare standard malloc with jemalloc/tcmalloc performance.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github