Gnome terminal scrollback lines?

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?


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.


gnome-terminal (actually vte) indeed stores the scrollback in an immediately-deleted file under /tmp (more precisely: under the standard tempfile location influenced by $TMPDIR and maybe a few similar ones).

This design was chosen mainly for unlimited scrollback not to cause OOM errors. The disk is way less likely to get filled up, and even if that happens, it's less harmful to the whole system than running out of memory.

vte-0.40 (which will most likely appear in Ubuntu 15.10 W.W.) will compress and encrypt these files. This will shrink the required storage to approx third–fourth of its size (if your app produces X amount of data as plain text, somewhere between X/4 .. X/3 is a reasonable estimate for the storage that'll be required), and also gets rid of the privacy/security issue in case someone gets raw access to the hard drive.

We're planning to add an option to store the scrollback in memory, pretty much equally to as if your /tmp was on tmpfs. If everything goes as planned, this will appear in vte-0.42 and in turn in Ubuntu 16.04 X.X. LTS. I can't promise it, though.