This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-10-27
Channels
- # announcements (14)
- # aws (2)
- # babashka (12)
- # beginners (23)
- # calva (71)
- # cider (37)
- # clj-kondo (47)
- # cljs-dev (3)
- # clojure (55)
- # clojure-brasil (1)
- # clojure-europe (51)
- # clojure-nl (1)
- # clojure-norway (63)
- # clojure-poland (1)
- # clojure-seattle (1)
- # clojure-uk (3)
- # clojurescript (10)
- # conjure (3)
- # cursive (23)
- # data-science (5)
- # emacs (16)
- # events (1)
- # hoplon (16)
- # hyperfiddle (19)
- # introduce-yourself (1)
- # kaocha (5)
- # nyc (1)
- # portal (31)
- # practicalli (2)
- # reitit (3)
- # releases (4)
- # sci (28)
- # slack-help (13)
- # sql (4)
- # squint (40)
- # tools-build (25)
- # tools-deps (10)
Hello! Calva launches clojure-lsp
the process. but it takes 10GB of memory :face_with_peeking_eye:
How to reduce its memory usage and what is the safe minimal amount for M1 Mac?
Interesting, is your project huge?
Could you try:
.lsp/config.edn
{:java nil}
but if it's a huge clojure project, it may not make that differenceI just removed the cache. restarted everything and it is all better now - only takes 35 MB yet. Such relieving 😊
ah yeah... I was to recommend that, you are not the first one which the cache for some crasy reason caches a huge old analysis
hum, I have a guess it's the post startup analysis which are mostly java analysis, did you try to disable java?
That gave me the idea that we should have a command to tell how the project in terms of analysis behave, like how many namespaces and how many keywords, that may help debug these kind of issues and it's not hard to implement
If the 10GB is too much for your machine, @U7S4LP2TD, you can tell Calva to not autostart clojure-lsp. You’ll not have all the functionality, but it is a competent Clojure environment still. Here’s hoping we will figure out how to calm down the memory consumption!
10gb for clojure-lsp is too much, I never saw a project use that even https://github.com/metabase/metabase which is the biggest clojure codebase I know, there is something weird here
I’m often running with 15+ projects open at the same time. Some pretty big. I have not seen clojure-lsp being the major memory hog on my machine. I don’t think it totals to 10GB even.
fwiw I work on metabase (200,000 LOC) with calva on an M1 Mac too. clojure-lsp generally uses about 8GB-10GB of my memory.
I'll work on these analysis count be available on serverInfo command so we can understand better on projects what takes lot of mem, my biggest guess are keywords and/or java analysis
ls -lh .lsp/.cache/db.transit.json
gives me 350MB
yeah, for metabase that makes sense, which is quite different from @U7S4LP2TD’s cache
@U7S4LP2TD just did a push to master adding analysis-summary
field, that may contain the count of some analysis which may help understand how big a project is and what is taking that much mem, it should be available in some mins in #C032YH7P0R2, would be great if you could test that
Download from that channel #C032YH7P0R2 the latest one for your pc, extract the zip, change calva to point to that path, restart vscode, and then call the comand Clojure LSP server info
Clojure LSP server info
command worked with the old version, but after the upgrade IDK where the output goes, even when I switched to the old version. 😞
Where may the out go?
I think calva prints it right @U0ETXRFEW?
it printed but with a huge delay, but. for the old version. now printing for the new version...
https://pastebin.com/f06FKHtJ takes 10 mins to output 😱
"analysis-summary": {
"external": {
"keyword-usages": 3340170,
"java-class-definitions": 34412,
"keyword-definitions": 207230,
"symbols": 0,
"java-member-definitions": 282904,
"var-usages": 0,
"namespace-definitions": 1582,
"java-class-usages": 0,
"var-definitions": 18033
},
"internal": {
"keyword-usages": 343307,
"java-class-definitions": 0,
"keyword-definitions": 4870,
"symbols": 904,
"java-member-definitions": 0,
"var-usages": 410351,
"namespace-definitions": 1942,
"java-class-usages": 3739,
"var-definitions": 30509
}
},
3M keywods 😅not in your project, but in some dependency, clojure-lsp should have a way to disable keyword analysis and maybe we should discard keyword-usages from external deps :thinking_face: which would result in way less things to have in memory + cache. I'll work on that but should take some days

I have a shizload of extensions in VSCode. Do you think they could be responsible for all this? My suspects other JVM languages. Especially Groovy - it has some JVM tricks.
@U0123R34Q9Y would be great if you could get the server info as well for metabase
@U7S4LP2TD Good news: • I improved clojure-lsp external analysis to drop keyword-usages as we don't really use it, so your 3M keywords will be gone and use way less memory probably • I implemented ways to improve memory usage disabling specific features/analysis • there is a doc about troubleshooting memory usage, check https://clojure-lsp.io/troubleshooting/#high-memory-usagefor more details This is already available on #clojure-lsp-builds but will be available on next release (couple of days), I hope it helps!

this config.edn
{:analysis {:java {:class-definitions false :member-definitions false}} :java nil}
this binary
this output: https://pastebin.com/9HCEtveL"analysis-summary": {
"internal": {
"keyword-usages": 344105,
"keyword-definitions": 4872,
"instance-invocations": 1049,
"protocol-impls": 990,
"local-usages": 215625,
"namespace-alias": 19801,
"namespace-usages": 21144,
"symbols": 907,
"var-usages": 411432,
"namespace-definitions": 1944,
"java-class-usages": 3753,
"locals": 134118,
"var-definitions": 30603
},
"external": {
"namespace-definitions": 1595,
"namespace-usages": 3811,
"namespace-alias": 2926,
"var-definitions": 18178,
"keyword-definitions": 207230,
"protocol-impls": 3247
}
},
Ok, so you don't have the 3M keywords anymore which is good, and I don't think java is being the issue here, but maybe the keywords are, so could you try with:
{:analysis {:keywords {:definitions false
:usages false}}}
also, make sure you remove your .lsp/.cache
during those testsbesides that your proejct doesn't seem that big, I'd expect way less memory than 10GB after this 3M elements removal
"analysis-summary": {
"internal": {
"instance-invocations": 1049,
"protocol-impls": 990,
"local-usages": 215625,
"namespace-alias": 19801,
"namespace-usages": 21144,
"symbols": 907,
"var-usages": 411432,
"namespace-definitions": 1944,
"java-class-usages": 3753,
"locals": 134118,
"var-definitions": 30603
},
"external": {
"java-class-definitions": 34443,
"java-member-definitions": 283046,
"namespace-definitions": 1582,
"namespace-usages": 3799,
"namespace-alias": 2919,
"var-definitions": 18034,
"protocol-impls": 3237
}
},
you need the JVM version, not the native-image, there are 2 ways:
• you can find it in #C032YH7P0R2 as well, but it's the clojure-lsp-standalone.jar, but you need to have a second executable file like clojure-lsp
that will java -jar clojure-lsp-standalone.jar
• you can clone clojure-lsp repo and run bb debug-cli
which should generate a clojure-lsp
JVM binary
no, the clojure-lsp
file you need to create that inside has a java -jar clojure-lsp-standalone.jar
should this:
(defn ^:private server-info [{:keys [db*]}]
(let [db @db*]
{:project-root-uri (:project-root-uri db)
:server-version (shared/clojure-lsp-version)
:clj-kondo-version (lsp.kondo/clj-kondo-version)
:log-path (:log-path db)
:project-settings (:project-settings db)
:classpath-settings (:classpath-settings db)
:client-settings (:client-settings db)
:final-settings (settings/all db)
:classpath (:classpath db)
:cljfmt-raw (binding [*print-meta* true]
(pr-str (f.format/resolve-user-cljfmt-config db)))
:analysis-summary (q/analysis-summary db)
:port (or (:port db)
"NREPL only available on :debug profile (`bb debug-cli`)")}))
include JVM version? I can submit a PR a bit later. 🙂 WDYT?I never needed that for debugging, having >java11 is enough, but wouldn't harm have that as well when not a graal image