Benchmark Report: Analyzing the Time-Space Trade-off in Memory Allocators (hakozuna vs tcmalloc)

Published: (January 18, 2026 at 10:17 PM EST)
2 min read
Source: Dev.to

Source: Dev.to

hakozuna repository

Benchmark Overview

A custom memory allocator, hz3 (referred to as hakozuna), was evaluated against two industry‑standard allocators:

  • tcmalloc (Google)
  • mimalloc (Microsoft)

The focus was on the trade‑off between execution speed and memory footprint (RSS).

Test Environment

  • CPU: AMD Ryzen 9 9950X
  • Runs per test: 5 (median values reported)

Results

1. Espresso (Real‑world simulation)

AllocatorTimeRSSNotes
tcmalloc2.43 s9.7 MBFastest, but highest memory usage
mimalloc2.45 s4.0 MBBalanced
hakozuna2.75 s2.6 MBSlowest (+13 %), but lowest memory

2. Alloc‑test (Synthetic)

AllocatorTimeRSSNotes
tcmalloc1.99 s18.2 MB
mimalloc2.00 s22.0 MB
hakozuna2.51 s14.5 MBSmallest footprint

Analysis

The Cost of Speed

  • tcmalloc achieved the fastest execution times in both benchmarks.
  • It consumed significantly more memory (≈ 3.7× higher RSS in the Espresso test: 9.7 MB vs 2.6 MB).
  • The allocator aggressively caches freed memory in thread‑local storage, minimizing locking and CPU overhead at the expense of a larger memory footprint.

The Cost of Frugality

  • hakozuna consistently recorded the lowest RSS.
  • This is due to an aggressive purging strategy that returns unused pages to the OS and a compact metadata design.
  • The reduced memory usage comes with a modest increase in execution time.

Choosing the Right Allocator

  • Latency‑sensitive applications with ample RAM: tcmalloc or mimalloc remain superior choices.
  • Memory‑constrained environments (e.g., high‑density microservices, embedded systems): hakozuna offers a viable alternative by markedly lowering memory consumption, accepting a slight CPU penalty.

Conclusion

The benchmark underscores that “performance” is not a single metric. It is always a balance between time (execution speed) and space (memory usage). Selecting an allocator should be guided by the specific priorities of the target workload.

Back to Blog

Related posts

Read more »