Skip to content

Uses a huge amount of memory #3013

Closed
Closed

Description

@honbolau

When I use AI extensively in a session, opencode's memory usage will keep increasing until it gets stuck.

Image

Activity

  1. github-actions commented on Oct 7, 2025

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if none of these address your specific case.

  2. rekram1-node commented on Oct 7, 2025

    @rekram1-node
    Contributor

    yeah current performance leaves a LOT to be desired, we are currently rewriting tui and it should be done this week most likely. It will have a lot of performance improvements.

  3. veracioux commented on Oct 8, 2025

    @veracioux
    Contributor

    Not sure if relevant to this issue, but one thing I have noticed is that when I run a debugger and either the server or the TUI stays paused on a breakpoint for a while, I would run out of memory on my system within a minute.

    I'm guessing this might be because of messages queuing up and/or this code: https://github.com/sst/opencode/blob/c93c0d402d3130c6e69129395993ac1776132234/packages/opencode/src/server/tui.ts#L12

  4. dkmnx commented on Oct 16, 2025

    @dkmnx

    I'm also experiencing this with v0.15.3.

  5. rekram1-node commented on Oct 16, 2025

    @rekram1-node
    Contributor

    @dkmnx what kind of project is it? Perhaps lsp servers are eating up the memory

  6. dkmnx commented on Oct 16, 2025

    @dkmnx

    @rekram1-node, its a rust project.

  7. rekram1-node commented on Oct 16, 2025

    @rekram1-node
    Contributor

    @dkmnx is it fixed if you do:
    opencode.json

    {
    "lsp": {
        "rust": {
          "disabled": true
        }
      },
    }
    
  8. GitMurf commented on Oct 28, 2025

    @GitMurf
    Contributor

    Any updates here or suggestions from anyone? In my tiny neovim config directory I am getting large spikes in memory and cpu while streaming in chat responses. I am using WSL.

  9. rekram1-node commented on Oct 28, 2025

    @rekram1-node
    Contributor

    rewrite ships soon, hard to say what is causing your issue, maybe dry disabling the lua lsp?

    {
    "lsp": {
        "lua-ls": {
          "disabled": true
        }
      },
    }
    
  10. GitMurf commented on Oct 28, 2025

    @GitMurf
    Contributor

    rewrite ships soon, hard to say what is causing your issue, maybe dry disabling the lua lsp?

    Oh is it a full rewrite using opentui?

  11. rekram1-node commented on Oct 28, 2025

    @rekram1-node
    Contributor

    Yes, all the go code will be gone all the core logic stays.

  12. hmnd commented on Nov 13, 2025

    @hmnd

    @rekram1-node if I understand correctly, the rewrite is shipped with v1.0? I'm still experiencing debilitating memory usage caused by opencode starting a ton of lsp servers

    Image
  13. 12 remaining items

  14. kanielrkirby commented on Nov 28, 2025

    @kanielrkirby

    hmm okay we will look into it...

    Happy to test some things if you need in my free time. Otherwise, wish you luck.

  15. LautaroGScholtus commented on Jan 12, 2026

    @LautaroGScholtus

    limit the resources for opencode process
    systemd-run --user --pty -p MemoryMax=8G -p CPUQuota=400% opencode
    until they resolve the memory leak

  16. apekros commented on Jan 15, 2026

    @apekros

    @dkmnx is it fixed if you do: opencode.json

    {
    "lsp": {
        "rust": {
          "disabled": true
        }
      },
    }
    

    For me yes this resolves it. Otherwise it becomes an unmanageable amount of memory usage.

  17. rekram1-node commented on Jan 15, 2026

    @rekram1-node
    Contributor

    interesting...

  18. apekros commented on Jan 15, 2026

    @apekros

    interesting...

    Claude Code with rust-analyser LSP enabled does not have the same issue, ghostty/nixos if that helps at all either.

  19. rekram1-node commented on Jan 15, 2026

    @rekram1-node
    Contributor

    their lsp serves different purposes and is only agent invoked afaik so im not surprised, but rust lsp is extremely memory hungry anytime I open rust projects in my ide it swallows a lot.

    We should figure out how to mitigate this tho..

  20. apekros commented on Jan 15, 2026

    @apekros

    their lsp serves different purposes and is only agent invoked afaik so im not surprised, but rust lsp is extremely memory hungry anytime I open rust projects in my ide it swallows a lot.

    We should figure out how to mitigate this tho..

    ah okay understood. would be great to mitigate it, it's only an issue for me on RAM limited VMs as it quickly grows to eat up >16gb

  21. KaranjotVendal commented on Feb 4, 2026

    @KaranjotVendal

    Just here to mention I think I am having the same issue with my opencode version (1.1.51). I tried building with the following Fixes PR #11717 and PR #10914 still doesn't help. I am using an omarchy machine.

    Image

  22. broskees commented on Feb 7, 2026

    @broskees

    running into this too ):

  23. AhmedBenyahia commented on Feb 15, 2026

    @AhmedBenyahia

    I've noticed this too from the first time I tried it. I thought it's just my PC having issues. Now it's been two weeks and i am sure it's opencaude. I am running it in wsl. Honestly, it's very annoying as I have to kill my IDE and restart everything, It will also stop in the middle of the task

  24. sjdweb commented on Mar 12, 2026

    @sjdweb

    If you're running opencode in tmux on Linux, OOM kills are worse than you'd expect. The kernel doesn't just kill opencode. It killed my user systemd, which took tmux and my whole session with it.

    I'm capping opencode with a systemd memory scope now. Alias in .zshrc / .bashrc:

    # Memory-limit opencode so OOM kills don't take out your session
    alias opencode="systemd-run --user --scope -p MemoryMax=8G -p MemorySwapMax=2G --description=opencode $HOME/.opencode/bin/opencode"

    Set MemoryMax to whatever makes sense for your box (I'm on 16G, so 8G). The total ceiling is 10G (8G RAM + 2G swap). If opencode blows past the limit, the cgroup kills it and only it.

    Note: if you run multiple opencode sessions, each gets its own 8G cap independently.

  25. thdxr commented on Apr 2, 2026

    @thdxr
    Member

    Closing in favor of #20695 where we're collecting all memory-related problems. Please follow that issue for updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

badbugSomething isn't workingperfIndicates a performance issue or need for optimization

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions