-
Notifications
You must be signed in to change notification settings - Fork 69
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
find-symbol can fail with "Requested array size exceeds VM limit" #245
Comments
Side note, the pinpointed code seems a good target for parallelization. Perhaps if done with reducers, the change wouldn't be too invasive. |
One last note, |
I further debugged this.
(defn foo
[{:keys [x]}]
(go-loop []
)) ...Namely:
You can apply this patch, and easily reproduce the issue:
|
thanks for the really good analysis. we have several probs with core.async as far as i remember due to its macro heavy nature. will have a closer look, ta |
Hey there, have you had a chance (or foresee one soon enough)? Btw, this issue report is a bit messy, it boils down to the last comment. I can close + re-create this ticket if that tidies up things. |
I've been hit by this as well. When commenting out https://github.com/clojure-emacs/refactor-nrepl/blob/master/src/refactor_nrepl/analyzer.clj#L53 it seems to run without the OOM, which I think makes sense, as I can imagine the total ast for this project would be rather large? |
@slipset I just had the same error occur on a smaller project (8k lines of clojure).
This is the same stacktrace as in the OP, but the error is slightly different. Looking at the stacktrace |
Hi, thanks for attending the issue! Yes I could still reproduce it. Updated repro instuctions are as follow:
My env:
|
I think this is still related to the problem I tried to solve in #278. Let's try the other way: (def ast
(refactor-nrepl.analyzer/ns-ast (slurp "test/resources/testproject/src/com/example/vemv.clj"))) if we now try to stringify the result, like this: (str ast) again - we get OOM. This is more or less what I fixed in #278. Lets instead redirect output directly to file: (with-open [w (clojure.java.io/writer "/tmp/ast.txt")]
(binding [*out* w] (pr ast))) Now, after few minutes (and assuming you had enough free space on your drive) you can see where is the problem . Generated file is gigantic. I interrupted entire dump after reaching 37GB. That's insane :) |
@vemv Any hope of narrowing this done? I'm not sure how to tackle this one, but it's probably one of the most important outstanding issues in refactor-nrepl atm. Since eastwood manages to use |
As a thing that maybe can help, this wall of flags helps me avoid all sort of OOMs (most specifically, for stack-heavy workloads): [;; Prevents a specific type of OOMs:
"-XX:CompressedClassSpaceSize=3G"
;; Prevents trivial StackOverflow errors:
"-XX:MaxJavaStackTraceDepth=1000000"
;; Set a generous limit as the maximum that can be allocated, preventing certain types of OOMs:
"-Xmx24G"
;; increase stack size x6, for preventing SO errors:
;; (The current default can be found with
;; `java -XX:+PrintFlagsFinal -version 2>/dev/null | grep "intx ThreadStackSize"`)
"-Xss6144k"] Also @slipset's comment seems on point. Keeping an AST cache seems a delicate business: outdated data can grow without control, correct? So something like a core.cache Or keeping things simpler, one could have a per-run cache: things would be cached for a specific refactor-nrepl op, but not across ops. I realise one will have more cache misses this way, but one gains simplicity and a reduced chance of OOMs. Finally, one nice thing I came up for Eastwood recently is jonase/eastwood@aa569a5 . It might not be related directly to our issue here, but omitting core.async exceptions can be good in other contexts / for other issues. |
Looks like we have a bit of a bug in the cache, in the sense that it's append-only and old shit is never thrown out. On the other hand it won't grow on it's own. Unless you're using the refactoring a lot and/or have a very large change set I doubt this is it. I'll add another issue tracking that (should be very easy to fix), but I think this one here is something different. edit: I just did a quick read-through of the cache code and it looks OK. It won't grow out of bounds. We also know that a single file can produce an AST that's too large to handle. Guess the next step might be to see what sort of recursion happens when such an AST is created... |
Yes the #245 (comment) repro hints so |
Hi there,
I've faced this issue repeatedly. In the past I had worked around it via
:jvm-opts ["-Xmx18G"]
, but today I hit it again (long time no see!). I could try setting an even higher bound, but I guess a GH issue will be more useful.The error is:
*Messages*
Interestingly, I can reproduce the error via the repl, skipping the middleware.
...and further playing at the repl, I could find the exact expression at fault:
refactor-nrepl/src/refactor_nrepl/find/find_symbol.clj
Lines 138 to 140 in bb27d13
I can run for example
And it will reliably OOM.
Let me know if I can help you reproduce the error again. Perhaps you have it easy by setting a deliberately small
-Xmx
.Victor
The text was updated successfully, but these errors were encountered: