Ubuntu – Gnome terminal scrollback lines

gnome-terminal

Currently I have set the scrollback setting of gnome terminal (Edit -> Profile Preferences -> Scrolling) to 10000 lines. I am tempted to tick Unlimited, but I am afraid this could lead to memory crashes (if I leave a program with lots of output running overnight, I wouldn't like it to crash because of this).

My questions are:

  1. Are these scrollback lines stored in memory, or are they cached in a file on disk?

  2. If I change from 10000 to 100000 or to 1 million, am I still safe? What parameters (RAM, free disk space, number of open terminals) I need to take into account)? Is selecting Unlimited safe?

Best Answer

It's apparently stored in deleted files on disk, according to very interesting blog post:

I could just look at what files gnome-terminal had open, so lsof to the rescue. Then I found it was being sneaky, it had a number of files called /tmp/vteXYZ1tv open, but it had already deleted them. Thus you can't see them when browsing, and they will be removed when the program closes. This makes sense, it means that when the process is closed, it doesn't matter how (at least I think), the space of the files can be reclaimed, i.e. we won't get leftover files on a program crash, or a kill -9. They can be restored though, my way (there are probably others), was to do a ls -l /proc/<gnome-terminal pid>/fd to see what they point to. Then you can cat these to make a new file. These are just a verbatim copy of the terminal output. No compression. No nothing. As it turns out, one of my terminal history's was almost 900 MB! But that was only after random data being spat out very quickly for quite a while, unlikely to happen in ordinary usage.

And I'll stress this again: The poster had run base64 < /dev/urandum for a while, looking for increases in memory or disk usage - 900MB would be exceptional usage.

Related Question