Skip to content

Conversation

@twdamhore
Copy link
Owner

Summary

Fixes memory not being returned to OS after serving large files.

Root cause: glibc's default allocator keeps freed memory for potential reuse instead of returning it to the OS.

Fix: Use jemalloc which has better memory return behavior.

Changes

  • Added tikv-jemallocator dependency
  • Set jemalloc as global allocator in main.rs

Test plan

# Build and install
cargo build --release
sudo cp target/release/serabutd /usr/local/bin/
sudo systemctl restart serabutd

# Serve a large file, then check memory after transfer completes
watch -n1 'ps -o rss= -p $(pgrep serabutd)'

Memory should drop back down after file transfer completes.

🤖 Generated with Claude Code

glibc's default allocator doesn't return freed memory to the OS,
causing memory to stay high after serving large files. jemalloc
has better memory return behavior.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@twdamhore twdamhore merged commit e0e0292 into main Jan 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant