You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
High memory usage: Bun's SQLite maps entire DB file into process address space via mmap #22429
On long-running sessions, the opencode process footprint grows to several GB. Profiling with footprint on macOS shows ~1.8 GB attributed to IOAccelerator — this is SQLite's memory-mapped pages, not actual application data.
The root cause: Bun's bundled SQLite sets a large mmap_size by default, unlike upstream SQLite which defaults to mmap_size = 0. As a result, the entire DB file is mapped into the process address space. With a 1.1 GB opencode.db, this alone accounts for ~1.8 GB of process footprint regardless of how much data is actually accessed.
Fix
Adding PRAGMA mmap_size = 0 in db.ts restores the standard SQLite default. SQLite then uses its internal page cache (already configured at ~64 MB via cache_size = -64000) instead of mmap. This caps SQLite's memory contribution at ~64 MB regardless of DB file size.
The performance impact is negligible — mmap vs read() is a sub-millisecond difference on cache misses, completely dwarfed by LLM API call latency.
If your issue is distinct (e.g., specifically about SQLite mmap being the root cause), please add a comment to the Memory Megathread (#20695) linking back here, as maintainers are consolidating memory reports there.
Activity
github-actions commentedon Apr 14, 2026
This issue might be a duplicate of existing issues. Please check:
If your issue is distinct (e.g., specifically about SQLite mmap being the root cause), please add a comment to the Memory Megathread (#20695) linking back here, as maintainers are consolidating memory reports there.
github-actions commentedon Jul 3, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.