Skip to content
Discussion options

You must be logged in to vote

Why --ulimit memlock=-1:-1 for Bun Docker

This flag is about memory locking (mlock), not total memory consumption.

What it does

  • memlock = max locked-in-memory address space
  • -1:-1 = unlimited soft and hard limits
  • This allows Bun to lock memory pages, preventing them from being swapped to disk

Why Bun needs it

Bun uses memory-mapped files and locked memory for:

  1. JavaScriptCore JIT - JIT-compiled code needs locked pages
  2. Fast file I/O - mmap for reading files
  3. SQLite - uses mlock for database pages

Impact of NOT setting it

Without this flag, you may see:

  • Slower performance (pages get swapped)
  • Potential crashes if mlock fails
  • Warning: failed to lock memory

For Kubernetes

You can set resour…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@karfau
Comment options

Answer selected by karfau
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants