tern icon indicating copy to clipboard operation
tern copied to clipboard

Tern out of heap - Emacs hangs

Open phuhl opened this issue 8 years ago • 1 comments

First sometimes now regularly tern crashes randomly and hangs my emacs with it. Using tern --verbose gave me this output:

<--- Last few GCs --->

[12548:0379F560]   392882 ms: Mark-sweep 705.8 (939.1) -> 705.8 (929.1) MB, 1456.3 / 0.0 ms  (+ 0.0 ms in 0 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 1456 ms) last resort GC in old space requested
[12548:0379F560]   394355 ms: Mark-sweep 705.8 (929.1) -> 705.8 (929.1) MB, 1473.4 / 0.0 ms  last resort GC in old space requested


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0609631D <JSObject>
    1: /* anonymous */(aka /* anonymous */) [C:\Users\Philipp\AppData\Roaming\npm\node_modules\tern\lib\def.js:~239] [pc=07452926](this=2E2841A1 <undefined>,_self=19DF6A1D <JSObject>,args=19DF6BC5 <JSArray[1]>)
    2: CallExpression(aka CallExpression) [C:\Users\Philipp\AppData\Roaming\npm\node_modules\tern\lib\infer.js:~1898] [pc=0744C39D](this=2E2841A1 <undefined>,node=2D020691 <Node map = 35B48679>...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

My Tern-version is 0.21, my Emacs-version is 24.5.1 i686-pc-mingw32, my Emacs-tern-plugin is version 20170925.1333, my Emacs company-tern version is 20161004.1147, OS is Win 10 64bit with 16GB RAM. All of them (except for emacs) are the latest as far as i see.

I know there is another issue concerning a similar problem (https://github.com/ternjs/tern/issues/583). My particular issue is (besides tern crashing) that tern takes my emacs with it. It hangs for a minute or so before becoming responsive again. As this is happening quite regularly now that renders my setup kind of useless.

I sadly can not provide you with the code i am using. If you need my .emacs file, etc. take a look at https://github.com/phuhl/emacs.d, especially https://github.com/phuhl/emacs.d/blob/master/starter-kit-js.org (nothing fancy there, though).

Nevertheless, thank you for the general awesomeness of tern and providing it.

phuhl avatar Nov 25 '17 19:11 phuhl

To unfreeze Emacs, start hitting C-g multiple times. It will unfreeze because this is universal "stop what are u doing now" command to emacs elisp core. To "fix" this better, add some timeout into code which is responsible for contacting tern in elisp layer. You may either advise such function or do monkey patch.

consciencia avatar Sep 02 '18 19:09 consciencia