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 / high CPU #1036

Closed
borkdude opened this issue Oct 7, 2020 · 2 comments
Closed

Memory leak / high CPU #1036

borkdude opened this issue Oct 7, 2020 · 2 comments
Assignees
Labels
bug Something isn't working
Projects

Comments

@borkdude
Copy link
Member

borkdude commented Oct 7, 2020

Repro:

$ clj -J-Xmx1g
Clojure 1.10.1
user=> (require '[clj-kondo.core :as clj-kondo])
nil
user=> (dotimes [i 10] (do (clj-kondo/run! {:lint ["src"]})))
nil
user=> (dotimes [i 10] (do (clj-kondo/run! {:lint ["src"]})))
nil
user=> (dotimes [i 10] (do (clj-kondo/run! {:lint ["src"]})))
nil
user=> (dotimes [i 10] (do (clj-kondo/run! {:lint ["src"]})))
nil
user=> (dotimes [i 10] (do (clj-kondo/run! {:lint ["src"]})))
user=> (dotimes [i 10] (do (clj-kondo/run! {:lint ["src"]})))
Execution error (OutOfMemoryError) at (REPL:1).
Java heap space

This is reported by VSCode users where clj-kondo is running as a long lived process.

Cause: we were holding on to a ctx argument in the hooks namespace by memoizing over it, which contains the entire linting state.

@borkdude borkdude self-assigned this Oct 7, 2020
@borkdude borkdude added this to Needs triage in clj-kondo via automation Oct 7, 2020
@borkdude borkdude moved this from Needs triage to High priority (next release) in clj-kondo Oct 7, 2020
@borkdude
Copy link
Member Author

borkdude commented Oct 7, 2020

Fixed with edfe1ff.

Proof:

$ clj -J-Xmx1g
Clojure 1.10.1
user=> (require '[clj-kondo.core :as clj-kondo])
nil
user=> (do (dotimes [i 100] (prn i) (clj-kondo/run! {:lint ["src"]})) (System/gc))

Monitor the Java process:

$ jps -m
$ top -pid 43477

No OOM, memory is back to reasonable amount after final GC.

borkdude added a commit to clj-kondo/clj-kondo.lsp that referenced this issue Oct 7, 2020
borkdude added a commit to clj-kondo/clj-kondo.lsp that referenced this issue Oct 7, 2020
@borkdude borkdude added bug Something isn't working next-release labels Oct 7, 2020
@borkdude borkdude moved this from High priority (next release) to Next release in clj-kondo Oct 7, 2020
@borkdude
Copy link
Member Author

borkdude commented Oct 7, 2020

Update to 2020.09.10-20201007.185225-22 to fix the problem.

clj-kondo automation moved this from Next release to Done Oct 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
clj-kondo
  
Done
Development

No branches or pull requests

1 participant