Search code examples
apacheloggingramnano

Why does Nano with error.log open use 40% of RAM?


Edit: I should clarify 40% of 2GB of RAM

I just happened to catch this on my sever, I had used nano before to open an error log and it was still open I don't know for how long. After killing that task, my ram usage dropped from just over 1GB to 250MB.

I remember coming across this before somewhere, I want to know how to prevent/avoid this in the future. I like nano for its simplicity but yeah, I guess be sure to kill the process or something.

Will have to look into remote status updates or something on the server's "livelihood" haha.


Solution

  • Maybe because error.log is a big file (you don't say how big is it). Did you try using a pager like less on it?

    less error.log
    

    You probably don't want to edit (i.e. have the opportunity to change) that error.log file, you just want to look inside it (with a terminal pager like less, or more, or most); a pager uses less memory than an editor, because it does not enable you to change the file.

    BTW, consider tuning your logrotate(8)

    Notice that nano, like all editors, need to keep in some complex data structures the content of the edited file, in such ways that modification is efficient. This explains why it takes a lot of memory. Since nano is free software (and so is less), you could study its source code for more details.