Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak? #129

Open
guibor opened this issue Jul 13, 2023 · 13 comments
Open

Memory leak? #129

guibor opened this issue Jul 13, 2023 · 13 comments

Comments

@guibor
Copy link

guibor commented Jul 13, 2023

Whenever I use chatgpt-shell I notice the performance of my Emacs slowly degrading and it's memory footprint increasing to amazing sizes.

#### System Info :computer:
- OS: darwin
- Emacs: 29.0.91
- Spacemacs: 0.999.0
- Spacemacs branch: develop (rev. 5ab4bde3e)
- Graphic display: t
- Running in daemon: nil
- Distribution: spacemacs
- Editing style: hybrid
- Completion: (compleseus csv dap emacs-lisp emoji ess fasd finance git graphviz html imenu-list javascript json latex lsp lua markdown multiple-cursors neotree octave osx outshine org pdf protobuf python ruby rust search-engine shell slack solidity spotify sql swift toc djvu tree-sitter typescript xkcd yaml treemacs)
- Layers:
```elisp
(dart
 (java :variables java-backend 'lsp)
 mu4e better-defaults clojure compleseus csv dap dart emacs-lisp emoji ess fasd finance git graphviz html imenu-list javascript json latex lsp lua markdown multiple-cursors neotree octave osx outshine pdf protobuf python ruby rust search-engine shell slack solidity spotify sql swift toc
 (tree-sitter :variables spacemacs-tree-sitter-hl-black-list
              '(js2-mode rjsx-mode)
              tree-sitter-syntax-highlight-enable t tree-sitter-fold-enable t tree-sitter-fold-indicators-enable t)
 typescript xkcd yaml treemacs)
  • System configuration features: ACL GIF GLIB GMP GNUTLS JPEG JSON LCMS2 LIBXML2 MODULES NATIVE_COMP NOTIFY KQUEUE NS PDUMPER PNG RSVG SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XIM XWIDGETS ZLIB
@xenodium
Copy link
Owner

Thanks for reporting. I think we would need more details. Would you be keen troubleshoot and see if you can perform specific actions and measure memory usage before and after? Can't say I have any Emacs experience in this space. I could use the help.

@guibor
Copy link
Author

guibor commented Jul 13, 2023

What specific actions or extra details do you suggest? Happy to help.

@xenodium
Copy link
Owner

Can't say I'm familiar with debugging Emacs memory issues. Anything you can do to try to isolate user actions that lead to memory consumption (and measure) would be helpful. If you figure out a way to measure (maybe after explicitly invoking garbage collector), could also be used to check if memory is restored when shell buffers are killed.

@xenodium
Copy link
Owner

Source highlighting is pretty innefficient at the moment. Added chatgpt-shell-highlight-blocks so it can be turned off. Try that and see if you notice better performance.

Also, it'd be good to know if the sluggishness goes away if the shell buffers are killed.

@guibor
Copy link
Author

guibor commented Jul 15, 2023

I will try it out. I'm optimistic, because the times at which I feel the greatest lag are indeed when the shell refreshes to highlight a new code block (at times Emacs goes blank until the buffer refreshes).

Buffers killed doesn't seem to help though.

@guibor
Copy link
Author

guibor commented Sep 30, 2023

I can confirm that it is the block highlighting that is affecting performance. Might be worth optimizing.

@xenodium
Copy link
Owner

xenodium commented Oct 5, 2023

Not had a chance to look into this. In the mean time, maybe this helps (after clearning or killing shell buffers)? https://indieweb.social/@lispi314@mastodon.top/111184372065140896

(when (symbol-function 'malloc-trim)
  (add-hook 'post-gc-hook #'malloc-trim))

@guibor
Copy link
Author

guibor commented Oct 16, 2023

Thanks for the suggestion. 'malloc-trim is not defined though in my version of emacs (Mac osx)

@gopar
Copy link

gopar commented Aug 14, 2024

Looks like I've run into some issues as well. I've been having some sluggish/slow behavior in emacs for a while but couldn't pin it down until now. Looks like chatgpt-shell syntax highlighting is the source.

Only when there is visible colorized text (eg code block), that's when the slowness kicks in.

Turning off syntax highlighting for now

xenodium pushed a commit that referenced this issue Oct 16, 2024
@xenodium
Copy link
Owner

@gopar 231e8b0 may help. Want to give v1.13.1 a try?

@xenodium
Copy link
Owner

Gentle ping ;) @gopar did it improve since 231e8b0? Ok to close issue?

@gopar
Copy link

gopar commented Nov 26, 2024

Ah have not turned on syntax coloring since then. I did quick testing and it seems to be fine now (But again it was a very limited test). I've changed my config back to having syntax coloring so I'll know more if this still an issue in the coming weeks.

Personally I'm okay with closing. Can always re-open if it didn't fix it

@xenodium
Copy link
Owner

xenodium commented Nov 26, 2024

Thanks! Gonna close the issue for now. If you see it again, please reopen.

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

No branches or pull requests

3 participants