---
title: "A Database Without Dynamic Memory Allocation"
description: "TigerBeetle allocates all memory once at startup and never again, using fixed limits for connections, in-flight messages per client, replicas, message size and queries per message so that total memory is a simple compile-time sum."
url: "https://swe.quest/articles/a-database-without-dynamic-memory-allocation-4be7684fa723cb5d"
canonical: "https://tigerbeetle.com/blog/2022-10-12-a-database-without-dynamic-memory"
source: "TigerBeetle"
published: "2022-10-12"
difficulty: "medium"
kind: "Deep dive"
reading_minutes: 6
tags: ["memory-management","zig","databases","storage-engines","testing"]
---

# A Database Without Dynamic Memory Allocation

A post on [TigerBeetle](https://swe.quest/sources/tigerbeetle.md), published 2022-10-12, 6 min read, Deep dive. Original: [https://tigerbeetle.com/blog/2022-10-12-a-database-without-dynamic-memory](https://tigerbeetle.com/blog/2022-10-12-a-database-without-dynamic-memory)

## Summary

TigerBeetle allocates all memory once at startup and never again, using fixed limits for connections, in-flight messages per client, replicas, message size and queries per message so that total memory is a simple compile-time sum. Beyond avoiding GC and use-after-free, static allocation bounds overload, makes resource use predictable for operators, and lets assertions on pool availability surface sizing mistakes under fuzzing rather than as production resource exhaustion. Supporting choices include fixed-size, cache-line-aligned 128-byte account and transfer structs sent zero-copy over the wire, batched queries (up to 8191 per message), and an LSM forest whose in-memory portion is preallocated and kept bounded by small incremental flushes to disk.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Memory management](https://swe.quest/tags/memory-management.md) (Compilers & runtimes)
- [Zig](https://swe.quest/tags/zig.md) (Languages)
- [Databases](https://swe.quest/tags/databases.md) (Data & databases)
- [Storage engines](https://swe.quest/tags/storage-engines.md) (Data & databases)
- [Testing](https://swe.quest/tags/testing.md) (Engineering practices)

## Prerequisites

- dynamic vs static memory allocation
- LSM trees basics ([easy posts on Storage engines](https://swe.quest/tags/storage-engines.md?difficulty=easy))

## Keywords

TigerBeetle, Zig, TIGER\_STYLE.md, Cap'n Proto, LSM tree

## Related posts

- [The effect of switching to TCMalloc on RocksDB memory use](https://swe.quest/articles/the-effect-of-switching-to-tcmalloc-on-rocksdb-memory-use-97e46a9ddc75be5e.md): Cloudflare · 2021-02-03 · Medium · 8 min read · Memory management, Performance engineering, Linux, Storage engines
  Quicksilver's memory roughly doubled after its storage moved to RocksDB, climbing from about 15GB to 30GB over several days.
- [Synadia and TigerBeetle Pledge $512,000 to the Zig Software Foundation](https://swe.quest/articles/synadia-and-tigerbeetle-pledge-512-000-to-the-zig-software-foundation-124e30142ae18e3c.md): TigerBeetle · 2025-10-25 · Easy · 8 min read · Zig, Language design, Memory safety, Open source
  Synadia and TigerBeetle are jointly donating $512,000 to the Zig Software Foundation over two years, with no strings attached.
- [We rewrote large parts of our API in Go using AI: we are now ready to handle one billion databases](https://swe.quest/articles/we-rewrote-large-parts-of-our-api-in-go-using-ai-we-are-now-ready-to-handle-one-dae54753b5d31582.md): Turso · 2025-05-29 · Medium · 7 min read · Go, Scaling, Memory management, SQLite, Caching
  Turso's Go API proxy, which maps database URLs to physical servers, ran out of memory as customers created millions of databases programmatically.
- [Introducing Limbo: A complete rewrite of SQLite in Rust](https://swe.quest/articles/introducing-limbo-a-complete-rewrite-of-sqlite-in-rust-eb77d828af295b26.md): Turso · 2024-12-10 · Easy · 7 min read · SQLite, Rust, Formal methods, Testing, WebAssembly
  Limbo is Turso's from-scratch rewrite of SQLite in Rust that aims for full language and file-format compatibility, memory safety and a modern architecture.
- [An adventure in writing compatible systems](https://swe.quest/articles/an-adventure-in-writing-compatible-systems-f48d37f87fc6e365.md): Turso · 2025-08-28 · Medium · 4 min read · SQLite, Storage engines, Formal methods, Debugging, Rust
  Turso, a Rust rewrite of SQLite, hit a bug where every write after the database crossed 1GB made SQLite's integrity checks fail, even though Turso's own checks found the file intact.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
