syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.64k stars 4.89k forks source link

Spacemacs freezes from time to time. When this happens it eats up almost all memory and CPU. #1300

Closed x-ji closed 9 years ago

x-ji commented 9 years ago

OS X 10.10 user here. I've only used Spacemacs for 3 days but it has frozen multiple times, even in one day :( ... By "freeze" I mean it just doesn't respond to anything at all, be it mouse click or keyboard input. I had to sudo kill -9 to kill the process and restart it, losing unsaved changes in the meantime. Is there any way to get an error log or something such that I might look at it/attach it here so that it would be easier to figure out what happened? I figure it could have something to do with "persistent server" but I'm not sure.

tuhdo commented 9 years ago

Which Spacemacs version are you using?

x-ji commented 9 years ago

Pulled it on Sunday. Also installed Carbon Emacs on that day. Didn't do update since then.

tuhdo commented 9 years ago

By Carbon Emacs, do you mean Emacs for Emacs OS X? If so, which Emacs version is it?

x-ji commented 9 years ago

The CHANGELOG in .emacs.d says Spacemacs' version is Release 0.101.x (2015/04/13), seems that it's still up to date with the current master branch.

I followed the following instructions on the project homepage to install Emacs on OS X.

The version of Emacs seems to be 24.5

The recommended version for OS X is emacs-mac-port. It can be installed via homebrew with the following commands:

$ brew tap railwaycat/emacsmacport $ brew install emacs-mac

The default key handling is different from the official OS X port. To correct this you can add the osx layer to your dotfile layer list:

(setq-default dotspacemacs-configuration-layers '(osx))

Note that the emacs-mac-port server behaves differently than the regular Emacs server. Details can be found on the emacs-mac-port README.

tuhdo commented 9 years ago

So, is it default Spacemacs or have you added anything to your .spacemacs file? If you add some layer, it would be useful to list the layers you enabled. And does this symptom happen on which language mode or Emacs in general?

This PR is updating the emacs-mac-port link: https://github.com/syl20bnr/spacemacs/pull/1295, so maybe you are using older version. What's the output of M-x emacs-version?

x-ji commented 9 years ago

GNU Emacs 24.5.1 (x86_64-apple-darwin14.3.0, Carbon Version 157 AppKit 1347.57) of 2015-04-19

I have a .spacemacs file and the following are the layers enabled:

     osx
     auto-completion
     better-defaults
     (git :variables
          git-enable-github-support t
          git-gutter-use-fringe t)
     markdown
     org
     syntax-checking
     themes-megapack
     auctex
     iedit
     python
     javascript
     php
     ruby
     shell-scripts
     haskell
     html
     c-c++
     ess
     autohotkey

     visual-fill-column

where visual-fill-column is a custom layer to add the package visual-fill-column from melpa.

Seems to be happening in general. Happened when I was editing LaTeX and Python, and just then when I was going through my .spacemacs file it happened again......

tuhdo commented 9 years ago

Do you see some messages at the bottom when this freezing happens? When this freezing happens, even Ctrl-g doesn't work?

Probably a layer is causing this, i.e. when this happens, which is the last file (i.e. Python or Latex) you opened?

kendall commented 9 years ago

brew seems borked right now; I did an update and then:

==> Upgrading 1 outdated package, with result: emacs-mac emacs-24.5-z-mac-5.7 ==> Upgrading emacs-mac ==> Cloning http://www.math.s.chiba-u.ac.jp/~mituharu/emacs-mac.git Updating /Library/Caches/Homebrew/emacs-mac--git error: Unable to find 5fdc612745165110dff7d17c4c1eab8bb68e36aa under http://www.math.s.chiba-u.ac.jp/~mituharu/emacs-mac.git Cannot obtain needed commit 5fdc612745165110dff7d17c4c1eab8bb68e36aa while processing commit 866501efe0fdc0c29448e0aaf8696eb0a3c8fcd6. error: fetch failed. Error: Failed to download resource "emacs-mac" Failure while executing: git fetch -q origin

Anyone else seeing this?

Cheers, Kendall

On Tue, Apr 21, 2015 at 11:44 AM, Xiang Ji notifications@github.com wrote:

The CHANGELOG in .emacs.d says Spacemacs' version is Release 0.101.x (2015/04/13)

I followed the following instructions on the project homepage to installed Emacs on OS X.

The version of Emacs seems to be 24.5

The recommended version for OS X is emacs-mac-port. It can be installed via homebrew with the following commands:

$ brew tap railwaycat/emacsmacport $ brew install emacs-mac

The default key handling is different from the official OS X port. To correct this you can add the osx layer to your dotfile layer list:

(setq-default dotspacemacs-configuration-layers '(osx))

Note that the emacs-mac-port server behaves differently than the regular Emacs server. Details can be found on the emacs-mac-port README.

— Reply to this email directly or view it on GitHub https://github.com/syl20bnr/spacemacs/issues/1300#issuecomment-94844918.

x-ji commented 9 years ago

I think I didn't see any message. Ctrl-g isn't having any effect either. It just ... froze. Nothing seems to change inside of the interface, and it doesn't respond to anything. Strangely there isn't a spinning ball when I move the mouse over, and Activity Monitor doesn't treat Emacs as in an "app not responding" state. The mouse just remained in the shape of "pointer" and wouldn't change to "insert" even if I move it over some text.

What I meant is that it happened multiple times, and each time I'm just working on one type of file. So for example the time when I was editing LaTeX, I was only working on LaTeX files throughout the whole session. The same for the Python session. If it's induced by a layer, then this layer could be a global one?

x-ji commented 9 years ago

Although Activity Monitor doesn't treat it as "not responding", if I use normal "exit" from GUI on it it wouldn't exit, because nothing is being shown whatsoever. Even normal "force kill" from the GUI seems to not work. sudo kill -9 was the only thing that worked for me.

Is there anything I can do next time this happens to grab some debug information.

jupl commented 9 years ago

Not sure if it helps, but I've had it freeze like this when I tried to use helm-projectile while working on a web-mode file.

stormpat commented 9 years ago

@kendall Theres an open issue on the emacs-macport repo, https://github.com/railwaycat/homebrew-emacsmacport/issues/22

kendall commented 9 years ago

Thanks. I fixed it by removing the existing git repo in the brew cache.

On Wed, Apr 22, 2015 at 12:54 AM, Patrik Storm notifications@github.com wrote:

@kendall https://github.com/kendall Theres an open issue on the emacs-macport repo, railwaycat/homebrew-emacsmacport#22 https://github.com/railwaycat/homebrew-emacsmacport/issues/22

— Reply to this email directly or view it on GitHub https://github.com/syl20bnr/spacemacs/issues/1300#issuecomment-95033952.

x-ji commented 9 years ago

Turns out this freeze issue could be induced by my Mac running out of disk space... Somehow Emacs just enters a loop and keeps eating more and more memory without doing anything. I'll wait for a few more days to see the situation after I've cleaned up my disk.

x-ji commented 9 years ago

Unfortunately disk space doesn't seem to be related... Even when I have more than 10GB of free space Emacs is still freezing up and eating memory.

The following are stats reported by Activity Monitor:

screenshot 2015-04-24 13 57 45 screenshot 2015-04-24 13 58 05 screenshot 2015-04-24 16 33 42 screenshot 2015-04-24 16 33 56

My Mac only has 16GB of memory so I'm not sure what's going on. Also the memory usage of kernal_task doesn't seem to be normal either.

Also, now the CPU usage goes near 100% nearly every time I execute some command... If it doesn't freeze then it also takes 2 to 3 seconds to respond.

x-ji commented 9 years ago

Finally I did a clean reinstallation of Spacemacs(both .emacs.d and .spacemacs file) using the same Emacs installation, and the issue seems to be gone. I suspect it's caused by a private layer I created to use some melpa package, or some conflict with themes-megapack, though I'm not sure.

x-ji commented 9 years ago

No it's not the problem of a private layer... It's probably some variable set in custom-set-variables via Customization. I noticed that after I've set a certain variable(not sure what), on loading config.el, Spacemacs hangs for 10 seconds, and eats up to nearly 6GB of memory. Then, after it finally loads, it easily freezes.

The following is my customization settings:

;; Do not write anything past this comment. This is where Emacs will
;; auto-generate custom variable definitions.
(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(ahs-case-fold-search nil)
 '(ahs-default-range (quote ahs-range-whole-buffer))
 '(ahs-idle-interval 0.25)
 '(ahs-idle-timer 0 t)
 '(ahs-inhibit-face-list nil)
 '(global-auto-complete-mode t)
 '(global-linum-mode t)
 '(global-visual-line-mode t)
 '(js-indent-level 2)
 '(org-mobile-directory "~/DropBoxBackup/Dropbox/orgmode")
 '(org-mobile-files (quote (org-agenda-files "~/GoogleDrive/orgmode/")))
 '(org-mobile-inbox-for-pull "~/GoogleDrive/orgmode/from-mobile.org")
 '(ring-bell-function (quote ignore) t)
 '(standard-indent 2))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(company-tooltip-common ((t (:inherit company-tooltip :weight bold :underline nil))))
 '(company-tooltip-common-selection ((t (:inherit company-tooltip-selection :weight bold :underline nil)))))

Could it be global-auto-complete-mode?

tuhdo commented 9 years ago

If you remove the customization, does the freezing happen?

x-ji commented 9 years ago

As I said, after I did a fresh installation the problem disappeared. However it seems that if I start to do customization after the fresh install, the freezing seems to happen again. At least it seems to be the most obvious possibility as of now.

tuhdo commented 9 years ago

Probably you should remove the customization one by one to see which causes the problem. I suspect auto-complete-mode or maybe org-mobile keeps syncing?

x-ji commented 9 years ago

Yeah that was my thought. Unfortunately the problem was severe enough to the extent that I couldn't even invoke M-x customize-group before it froze... Also, editing the .spacemacs file and commenting out the customizations via an external editor seems to break Spacemacs. I'm trying another fresh install now.

x-ji commented 9 years ago

It seems to be working fine now after I enabled everything except for org-mobile, so I suppose it's because I didn't set it up correctly. Thanks for the help.

x-ji commented 9 years ago

I hate to say it but it's back again... Without any private layer nor auto-complete nor org-mobile in custom......

screenshot 2015-04-26 21 52 43

I'm not sure whether it could be related to https://github.com/syl20bnr/spacemacs/issues/1263 ...

At such a state of affairs I'm afraid I won't be able to use Spacemacs until I figure out what's happening at all...

x-ji commented 9 years ago

Also I realized when this happens, because it seems to require infinite memory beyond current memory capacity, Emacs constantly fills up disk space(presumably making virtual memory?) until it's full.

x-ji commented 9 years ago

In my case I can currently confirm that an abnormally large savehist file caused the issue each time and disabling savehist-mode solved it. Though I currently have no idea as to why this happened...

jawwada commented 9 years ago

how to do it, i mean remove kill ring from save hist

x-ji commented 9 years ago

@jawwada Already removed in commit bef15e7 and I didn't have problems since it's removed.

Danl2620 commented 7 years ago

Hi @syl20bnr, this issue is marked fixed, but I'm getting sporadic 10 second freezes in spacemacs. I have a call stack sample dump attached.

My spacemacs version is: 0.200.9@25.2.1 (spacemacs) My emacs version is: GNU Emacs 25.2.1 (x86_64-apple-darwin15.0.0, NS appkit-1404.13 Version 10.11.1 (Build 15B42)) of 2017-05-24

emacs_freeze_sample.txt

kpanic commented 6 years ago

This https://github.com/syl20bnr/spacemacs/issues/1905#issuecomment-129592455 helped for me. I was getting freeze after auto-completing in elixir-mode and maximum CPU usage (fan was turning on)

After I applied those settings in emacs24 I did not had this behaviour anymore