18

我在 ubuntu 14.04 上使用 tmux(实际上是带有 tmux 后端的 byobu)。

我的 tmux 使用 1GB 内存(VIRT 和 RES 中top),我已经使用了该clear-history命令。

现在我的回滚消失了,但内存使用量并没有下降。

这个 tmux 运行了很长时间,并且滚动了很多文本。top显示它总共使用了超过 1 小时的 CPU 时间。

可能是什么原因?

会不会有内存泄漏?

我可以尝试什么?

我无法重新启动它或做危险的事情,因为该会话运行一个需要大约一周才能完成的实验......

4

5 回答 5

10

tmux 中似乎存在一个错误,导致在清除历史记录时未释放内存。

这个错误一直存在到包括版本 1.9a,在版本 2.0 中修复。我将其发布为较晚的答案,因为 1.9a 版似乎仍在使用中(至少对我而言)。

https://groups.google.com/forum/#!topic/tmux-users/WiSZy6ft1As https://github.com/tmux/tmux/commit/28f23f18e9d79405a60348c4f7aeded33da9135b

于 2016-01-21T03:25:38.007 回答
5

由于没有人回答这个问题,我将提供我对正在发生的事情的猜测。

tmux为它的历史分配内存空间,当你用完更多的历史时,内存会增长。清除历史记录使其不可见,但不会释放实际内存。这意味着tmux可以使用每个打开窗格的总行数的内存,而不管这些窗格当前是否包含任何内容。

这可以说是一个错误,或者充其量是一个坏特性。

我没有解决办法。

于 2014-09-11T03:30:40.383 回答
4

Necropost,但这个问题一直困扰着我,直到最近。x86 xubuntu 18.04 上的 repos 中的 tmux 2.6 的内存使用量总是在一两天内上升到千兆字节。我删除了它并从源代码构建了 tmux 2.8。几天来,它的内存使用量一直很低。问题终于解决了。

于 2018-10-31T15:18:37.600 回答
3

tmux 2.5 中修复了另一个内存泄漏:

* Handle slow terminals and fast output better: when the amount of data
  outstanding gets too large, discard output until it is drained and we are
  able to do a full redraw. Prevents tmux sitting on a huge buffer that the
  terminal will take forever to consume.

* Do not redraw a client unless we realistically think it can accept the data -
  defer redraws until the client has nothing else waiting to write.

https://github.com/tmux/tmux/blob/91b220525b0406763dafb6698d2741bec580bc10/CHANGES#L257-L263

于 2018-05-07T12:37:52.777 回答
2

这不是错误,当您清除历史记录时,tmux 会立即释放内存。由 glibc 将其返回给内核,但它在这方面很差。您应该能够看到内存是空闲的,因为如果您清除 10000 行的历史记录,内存使用量将不会再次增长,直到历史记录再次达到 10000 行。

于 2015-01-13T23:57:35.983 回答