Konsole has the option to set scrollback line count and an alternative "infinite" where it just writes to a file on disk.
GIMP can also have that and can ask for which disk it wants you to use, so if you have a 20TB HDD to dedicate for that, might as well.
In this case, the most recent 10 or so remain in RAM, while others only have a reference to it, in RAM.