Robitx / gp.nvim

Gp.nvim (GPT prompt) Neovim AI plugin: ChatGPT sessions & Instructable text/code operations & Speech to text [OpenAI, Ollama, Anthropic, ..]
MIT License
890 stars 76 forks source link

`nvim_buf_add_highlight()` Causes High Memory Usage #229

Open yuukibarns opened 4 days ago

yuukibarns commented 4 days ago

After a long chat, about 300 lines, I found the memory usage of Neovim increased significantly from 40MB to 1.2GB. System monitor shows a consistent memory increase at the rate of 4MB/s when gp.nvim is writing response to the buffer and after the chat ends, the memory usage won't decrease but still the highest level.

228 fixes this.

yuukibarns commented 3 days ago

However, there is still a 5MB increase in memory after the commit. If further banned gp.nvim from writing to the buffer, the increase disappeared. Why such a smiple nvim_buf_set_lines() can cause relatively big memory usage increase?