开发者生态
morning
Linux 终端内存使用情况
摘要
I use terminals a lot。On most machines, I have anywhere from five to ten of them open across one to four desktops (there are 12 terminals open on two desktops on the machine I'm writing on)。
and
the
was
but
that
2026-05-11
1 阅读
约9分钟阅读
speckx
字号:
我经常使用终端。在大多数机器上,我在 1 到 4 个桌面上打开了 5 到 10 个终端(我正在编写的机器上的两个桌面上打开了 12 个终端)。我从 1996 年开始使用 Linux,所以使用 xterm,因为它是基准。我在 1998 年左右发现了 rxvt 并使用了几年。我不知道它是如何发展的,但大约三年前,我主要使用 lxterminal,但后来改用 alacritty,因为它做的大部分事情都是正确的,并且在 X11 和 Wayland 中都能工作(我被困在这两个世界之间)。然而,不到一年前,我发现了 kitty,它非常有吸引力,因为它与 alacritty 一样,而且还支持在终端中对照片进行像素完美渲染(使用 timg - https://github.com/hzeller/timg )……当您通过 SSH 连接到远程 Web 服务器时,这非常方便。我把大部分机器换成了 kitty 。大约六周前,我注意到我的一台机器非常缓慢,因为它淹没在交换中。这是一台相对较旧的机器,配有 i7 处理器和旋转磁盘……但它有 16G 内存,而且我没有做任何内存密集型操作,例如视频编辑或运行大型数据库。这提供了一个学习机会,我发现了 smem(https://www.selenic.com/smem/ ...在 Fedora 和 Debian 存储库中也可用)。它报告进程的内存使用情况(包括 USS、PSS - smem 声称这是查看内存使用情况、RSS 和 Swap 的更好方法)。我立即发现十只小猫已经把我所有的交换物都嚼完了。 50G 交换空间。 (我不知道为什么我的机器上有那么多东西 - 可能是一些失败或忘记的实验。)我杀死了所有的 kitty 实例并用十个 xterm 实例替换它们,并且已经满的 50G 交换空间完全是空的。 xterm 不是特别漂亮,但我不使用其他人会错过的东西,例如选项卡和菜单。我有点怀念透明度,但这没什么大不了的。由于 timg ,我会保留 kitty ,尽管这是一个相对罕见的用例。我开始将我的大部分机器切换回 alacritty ,并想知道从长远来看我应该使用什么。这启发我设计了一个测试:我会同时运行我正在考虑的每个终端 - 更好的是,一组在 Wayland 上,一组在 X11 上 - 然后在每个终端中运行相同的命令集。并测量内存使用情况。 Openbox / X11 在运行命令之前 PID 命令交换 USS PSS RSS 115733 st 0 2592 3008 12788 115892 xterm 0 6808 7414 17732 115207 lxterminal 0 6528 9891 41380 114856 /usr/libexec/gnome-terminal 0 10252 14984 52836 115034 /usr/bin/kitten __atexit__ 0 19772 19783 21168 114615 alacritty 0 34224 43478 98396 131279 konsole 0 35108 50308 101220 115005 kitty 0 56376 66584 129180 115381 ptyxis 0 54760 67603 144640 命令运行后 PID 命令交换 USS PSS RSS 115733 st 0 3396 3834 13780 115207 lxterminal 0 7800 11159 42656 115892 xterm 0 11640 12266 22748 114856 /usr/libexec/gnome-terminal 0 10692 15416 53340 115034 /usr/bin/kitten __atexit__ 0 21972 21983 23368 114615 alacritty 0 40188 49444 104408 131279 konsole 0 38528 54193 106256 115381 ptyxis 0 58252 71107 148316 115005 kitty 0 70716 80917 143568 KDE / Wayland 在命令运行之前 PID 命令交换 USS PSS RSS 30975 st 0 2924 3374 12832 31112 xterm 0 6460 6691 13204 7905 脚 0 5096 7110 17296 30850 rxvt 0 8936 9440 19248 29538 lxterminal 0 9200 14622 47240 29259 /usr/libexec/gnome-terminal 0 12168 19005 53420 29417 /usr/bin/kitten __atexit__ 0 22852 22864 24464 29098 alacritty 0 25468 28837 73416 43371 /usr/bin/konsole 0 27348 39068 130252 29401 小猫 0 46468 51520 105816 29690 ptyxis 0 73220 79204 141012 运行命令后 PID 命令交换 USS PSS RSS 30975 st 0 3204 3820 13836 31112 xterm 0 9888 10119 16632 7905 脚 0 8764 11114 21704 30850 rxvt 0 12872 13736 27096 29538 lxterminal 0 9824 15343 48804 29259 /usr/libexec/gnome-terminal 0 12660 19313 54056 29417 /usr/bin/kitten __atexit__ 0 22884 22896 24496 29098 alacritty 0 34188 37470 82580 43371 /usr/bin/konsole 0 33244 48094 145496 29401 kitty 0 53048 58032 112936 29690 ptyxis 0 75060 81130 143284 您可能会注意到一些异常情况:rxvt 不是在一台机器上测量的。各方面的控制都很差:终端大小不同,有不同的回滚缓冲区等。但由于上面的结果显示最小的内存使用量小于最大的内存使用量的十分之一,因此我们在这里不测量细微的差异。所以我不太担心。结果真的很有趣:我不认为我会找到一个比 xterm 内存使用更少的终端 - 但 st 以明显的优势击败它
这篇文章对您有帮助吗?
订阅66必读
每日精选科技资讯,直达你的邮箱