1

I want to open a large file in the server environment with emacs, but there is error: Memory exhausted--use C-x s then exit and restart Emacs as shown in the following figure. open the large file with emacs emacs error information

Please know that I intend to open the file with emacs in the server environment. The Linux is Centos. If your guys know this issue, please tell me in detail, use the figure to explain is the best.

Thanks!

  • 1
    Well... it looks like your server didn't have enough memory to open a file that large in Emacs. As you haven't offered any information to the contrary, I'm going to suggest that that was in fact what happened. Your other problem was deciding to open a near-1GB file in Emacs. I'm not sure why you wanted to do that, but you might try the vlf library which is designed for dealing with Very Large Files. See github.com/m00natic/vlfi (you can install it from GNU ELPA). – phils Jun 27 '16 at 4:46
  • hi @phils, thanks for your comments. Since I get used to emacs. So I want to use the emacs to open the log file. Do you know how to solve this. – Ke Tian Jun 27 '16 at 5:23
  • hi @phils, thanks for your advices. I have solved this issue with vlf. you can answer this question and I will accept it. I am going to suggest you that it is better to explain in detail so that other new one to emacs would understand it. For example. M-x: install-package vlf........ .By the way, could you explain the mechanism why emac is slow to open the large file without the vlf in emacs, and why become fast with vlf. Thanks! – Ke Tian Jun 27 '16 at 7:23
2

The vlf package can help here. The acronym stands for "Very Large Files", and it enables you to open such files in Emacs.

You can install it from GNU ELPA via the package manager:

M-x package-install RET vlf RET

Without a clever library like that, Emacs would not be a good choice of tool for inspecting such a massive file. Emacs normally loads a copy of the whole file into memory, and it was just never intended to process files as large as that. vlf facilitates it by only having parts of the file loaded into the Emacs buffer at any given time.

As a final note, you say this is a log file? You might consider implementing a log rotation strategy in order to limit the possible size of any given log file. If your logs are never allowed to reach that kind of size, you will not run into problems when you try to open them.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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