So, that's it. I am writing a lot of LaTeX, and lately emacs is hanging (becoming unresponsive) on almost every word I type, and I have to press C-g to regain control. It started happening around 4 weeks ago. At first it happened less frequently (once or twice a day) and it got worst and worst.

I am using Emacs 25.1 (compiled from source with default options), on Ubuntu Gnome 16.04 LTS. I use Prelude configuration.

I have been using Emacs without a problem for more than 5 years. Never had this kind of problem.

My questions is: how can I identify what is the source of the problem. What keeps making my Emacs hang?

  • 5
    Activate Options->Enter Debugger on Quit. There should be a debugger buffer with a backtrace on the next quit you trigger in your auctex-buffer. If you do not know what to do with the backtrace add it to your question above. I think somebody will have a hint where to look next.
    – Tobias
    Commented Oct 28, 2016 at 16:04
  • 1
    1. Did the problem start with Emacs 25.1? 2. What happens if you remove your init file from the equation: emacs -Q? 3. If you don't see the problem without your init file, recursively bisect the file (use comment-region'), to find the problem. If you do see the problem with emacs -Q` then please post a reproducible recipe (from emacs -Q) here or to M-x report-emacs-bug. (The latter is where bugs get fixed, not here. But posting here might get you some helpful info.)
    – Drew
    Commented Oct 28, 2016 at 17:03
  • 1
    Not a solution, but it's possible you've got garbage collection ("GC") triggering very frequently. This is something I've seen on Windows after having moved to 25.x. Emacs will pause during this process but, by default, there's not an easy way to see it's happening. Try putting (setq garbage-collection-messages t) in your init and seeing if you see garbage collection messages in your Messages buffer. Commented Oct 29, 2016 at 9:23
  • @Stuart This actually helped, thanks! However, only my echo area shows the message; they don't show up in *Messages*. Also, any clue why this happens with Emacs 25.1 and Windows combination?
    – legends2k
    Commented Feb 17, 2017 at 6:28
  • @legends2k Yes, you're right, they don't show up in Messages -- I'm not sure why I thought that at the time, so sorry for the confusion. To (not) answer your other question, I've no idea why this hits Windows worse than Linux (I use the same config on both and only see this on Windows, so I'm pretty sure it's platform-specific). I've managed to minimise the effect with the following: (setq gc-cons-threshold (* 511 1024 1024)) (setq gc-cons-percentage 0.5) (run-with-idle-timer 5 t #'garbage-collect) (setq garbage-collection-messages t) Commented Feb 20, 2017 at 22:04

1 Answer 1


I would approach this a few ways:

First, you'll want to identify if the problem reproduces in vanilla (i.e. non-configured, no Prelude) Emacs, or with your configurations. As Drew mentioned above, use emacs -Q to launch Emacs without any extra init.el configuration. If it does not reproduce here, then you're looking for a problem with a package or custom code you load in your configuration.

Second, if there is an actual error happening that you're then canceling with C-g, you can enable debugging with M-x toggle-debug-on-error. If it gives you a stack trace when it next hangs, you can use it to identify the cause.

Third, if it's not an error, it might just be really slow and need to be profiled. Use M-x profiler-start, probably choose just the CPU report, reproduce your problem, and then use M-x profiler-report. Your hang is probably occurring in the code path using the most CPU. Here is the Emacs documentation on profiling.

Fourth, and this is the longest shot, you could try compiling from the emacs-25 branch instead of the emacs-25.1 tag. This is something I would probably try, but is not very likely to solve your issue. However, if the bug is within Emacs, knowing that it reproduces on the latest code is useful. If you become certain the bug was introduced by changes to the Emacs source code, and you know a version where it did not reproduce, you can use git bisect and recompile a few times to identify the problem commit. I do not recommend this unless you are 95 percent confident it's a bug in Emacs without any configurations (emacs -Q).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.