【问题标题】:Many git processes running and exhausting available RAM许多 git 进程正在运行并耗尽可用 RAM
【发布时间】:2014-01-22 12:24:41
【问题描述】:

在我的 ubuntu 机器中,突然运行了多个 git 进程。这会消耗大部分内存导致我的机器停止工作

$ ps aux | grep git
1417676764 13890 8.0  0.2 32428 11584 ?        R    18:04   0:08 git ls-files --others --exclude-standard
1417676764 14143 8.5  0.3 32560 11696 ?        R    18:04   0:09 git ls-files --others --exclude-standard
1417676764 14380 8.1  0.2 32300 11476 ?        R    18:04   0:08 git ls-files --others --exclude-standard
1417676764 14518 8.9  0.3 32592 11768 ?        R    18:04   0:08 git ls-files --others --exclude-standard
1417676764 14851 8.3  0.2 32204 11372 ?        R    18:04   0:08 git ls-files --others --exclude-standard
1417676764 14994 8.3  0.2 32104 11196 ?        R    18:04   0:07 git ls-files --others --exclude-standard
1417676764 15127 9.0  0.2 32204 11368 ?        R    18:04   0:08 git ls-files --others --exclude-standard
1417676764 15261 8.2  0.2 31424 10544 ?        R    18:04   0:07 git ls-files --others --exclude-standard
1417676764 15392 8.0  0.2 31148 10260 ?        R    18:05   0:06 git ls-files --others --exclude-standard
1417676764 15524 8.0  0.2 31044 10136 ?        R    18:05   0:06 git ls-files --others --exclude-standard
1417676764 15662 8.3  0.2 31044 10140 ?        R    18:05   0:06 git ls-files --others --exclude-standard
1417676764 15794 8.7  0.2 31044 10136 ?        R    18:05   0:06 git ls-files --others --exclude-standard
1417676764 15938 8.7  0.2 30948  9992 ?        R    18:05   0:06 git ls-files --others --exclude-standard
1417676764 16073 8.3  0.2 30396  9444 ?        R    18:05   0:05 git ls-files --others --exclude-standard
1417676764 16197 8.9  0.2 30852  9868 ?        R    18:05   0:05 git ls-files --others --exclude-standard
1417676764 16334 9.2  0.2 30948  9992 ?        R    18:05   0:05 git ls-files --others --exclude-standard
1417676764 16473 8.2  0.2 29528  8708 ?        R    18:05   0:04 git ls-files --others --exclude-standard
1417676764 16611 8.3  0.2 29424  8484 ?        R    18:05   0:04 git ls-files --others --exclude-standard
1417676764 16783 7.7  0.1 28556  7612 ?        R    18:05   0:04 git ls-files --others --exclude-standard
1417676764 16891 8.0  0.2 28780  7884 ?        R    18:05   0:04 git ls-files --others --exclude-standard
1417676764 17019 8.0  0.1 28556  7608 ?        R    18:05   0:04 git ls-files --others --exclude-standard
1417676764 17145 9.5  0.2 29044  8016 ?        R    18:05   0:04 git ls-files --others --exclude-standard
1417676764 17289 8.4  0.1 28392  7332 ?        R    18:05   0:03 git ls-files --others --exclude-standard
1417676764 17427 7.8  0.1 28064  7132 ?        R    18:05   0:03 git ls-files --others --exclude-standard
1417676764 17582 7.4  0.1 27460  6488 ?        R    18:05   0:02 git ls-files --others --exclude-standard
1417676764 17756 7.9  0.1 27112  6156 ?        R    18:05   0:02 git ls-files --others --exclude-standard
1417676764 17854 9.2  0.2 28848  7912 ?        R    18:05   0:03 git ls-files --others --exclude-standard
1417676764 18001 9.6  0.1 27460  6488 ?        R    18:05   0:03 git ls-files --others --exclude-standard
1417676764 18130 6.6  0.1 26260  5392 ?        R    18:05   0:01 git ls-files --others --exclude-standard
1417676764 18256 7.7  0.1 26364  5636 ?        R    18:05   0:02 git ls-files --others --exclude-standard
1417676764 18390 6.3  0.1 25492  4720 ?        R    18:06   0:01 git ls-files --others --exclude-standard
1417676764 19260 43.5  0.2 29292 8488 ?        R    18:06   0:04 git ls-files --others --exclude-standard
1417676764 19386 45.5  0.2 28652 7796 ?        R    18:06   0:03 git ls-files --others --exclude-standard
1417676764 19514 52.8  0.2 30592 9644 ?        R    18:06   0:03 git ls-files --others --exclude-standard
1417676764 19685 46.5  0.1 24964 4212 ?        R    18:06   0:00 git ls-files --others --exclude-standard
1417676764 19774 0.0  0.0 13612   876 pts/1    S+   18:06   0:00 grep --color=auto git

这些过程会随着时间的推移而不断增加。

我用以下命令杀死了进程作为临时解决方案,

$ pkill git

但无法弄清楚 git 作为进程运行的原因。

$ pstree -apl 命令给了我以下输出。

  |-tmux,3001 -2
  |   |-bash,3002
  |   |   `-pstree,10343 -apl
  |   |-sh,3003 -c ~/tmux-powerline/powerline.sh left
  |   |   `-bash,3005 /home/prayag/tmux-powerline/powerline.sh left
  |   |       `-bash,3528 /home/prayag/tmux-powerline/powerline.sh left
  |   |           `-bash,3550 /home/prayag/tmux-powerline/powerline.sh left
  |   |               `-bash,3557 /home/prayag/tmux-powerline/powerline.sh left
  |   |                   |-git,3559 ls-files --others --exclude-standard
  |   |                   `-wc,3560 -l
  |   |-sh,3333 -c ~/tmux-powerline/powerline.sh left
  |   |   `-bash,3335 /home/prayag/tmux-powerline/powerline.sh left
  |   |       `-bash,3527 /home/prayag/tmux-powerline/powerline.sh left
  |   |           `-bash,3549 /home/prayag/tmux-powerline/powerline.sh left
  |   |               `-bash,3555 /home/prayag/tmux-powerline/powerline.sh left
  |   |                   |-git,3556 ls-files --others --exclude-standard
  |   |                   `-wc,3558 -l
  |   |-sh,3573 -c ~/tmux-powerline/powerline.sh left
  |   |   `-bash,3575 /home/prayag/tmux-powerline/powerline.sh left
  |   |       `-bash,3728 /home/prayag/tmux-powerline/powerline.sh left
  |   |           `-bash,3739 /home/prayag/tmux-powerline/powerline.sh left
  |   |               `-bash,3742 /home/prayag/tmux-powerline/powerline.sh left
  |   |                   |-git,3743 ls-files --others --exclude-standard
  |   |                   `-wc,3744 -l
  |   |-sh,3800 -c ~/tmux-powerline/powerline.sh left
  |   |   `-bash,3801 /home/prayag/tmux-powerline/powerline.sh left
  |   |       `-bash,3909 /home/prayag/tmux-powerline/powerline.sh left
  |   |           `-bash,3920 /home/prayag/tmux-powerline/powerline.sh left
  |   |               `-bash,3923 /home/prayag/tmux-powerline/powerline.sh left
  |   |                   |-git,3924 ls-files --others --exclude-standard
  |   |                   `-wc,3925 -l
  |   |-sh,3926 -c ~/tmux-powerline/powerline.sh left
  |   |   `-bash,3927 /home/prayag/tmux-powerline/powerline.sh left
  |   |       `-bash,4035 /home/prayag/tmux-powerline/powerline.sh left
  |   |           `-bash,4046 /home/prayag/tmux-powerline/powerline.sh left
  |   |               `-bash,4049 /home/prayag/tmux-powerline/powerline.sh left
  |   |                   |-git,4050 ls-files --others --exclude-standard
  |   |                   `-wc,4051 -l
  |   |-sh,4052 -c ~/tmux-powerline/powerline.sh left
  |   |   `-bash,4053 /home/prayag/tmux-powerline/powerline.sh left
  |   |       `-bash,4161 /home/prayag/tmux-powerline/powerline.sh left
  |   |           `-bash,4172 /home/prayag/tmux-powerline/powerline.sh left
  |   |               `-bash,4175 /home/prayag/tmux-powerline/powerline.sh left
  |   |                   |-git,4176 ls-files --others --exclude-standard
  |   |                   `-wc,4177 -l
  |   |-sh,4178 -c ~/tmux-powerline/powerline.sh left
  |   |   `-bash,4179 /home/prayag/tmux-powerline/powerline.sh left
  |   |       `-bash,4287 /home/prayag/tmux-powerline/powerline.sh left
  |   |           `-bash,4298 /home/prayag/tmux-powerline/powerline.sh left
  |   |               `-bash,4301 /home/prayag/tmux-powerline/powerline.sh left
  |   |                   |-git,4302 ls-files --others --exclude-standard
  |   |                   `-wc,4303 -l
  |   |-sh,4305 -c ~/tmux-powerline/powerline.sh left
  |   |   `-bash,4306 /home/prayag/tmux-powerline/powerline.sh left
  |   |       `-bash,4414 /home/prayag/tmux-powerline/powerline.sh left
  |   |           `-bash,4425 /home/prayag/tmux-powerline/powerline.sh left
  |   |               `-bash,4428 /home/prayag/tmux-powerline/powerline.sh left
  |   |                   |-git,4429 ls-files --others --exclude-standard
  |   |                   `-wc,4430 -l
  |   |-sh,4432 -c ~/tmux-powerline/powerline.sh left
  |   |   `-bash,4433 /home/prayag/tmux-powerline/powerline.sh left
  |   |       `-bash,4541 /home/prayag/tmux-powerline/powerline.sh left
  |   |           `-bash,4552 /home/prayag/tmux-powerline/powerline.sh left
  |   |               `-bash,4555 /home/prayag/tmux-powerline/powerline.sh left
  |   |                   |-git,4556 ls-files --others --exclude-standard
  |   |                   `-wc,4557 -l
  |   |-sh,4558 -c ~/tmux-powerline/powerline.sh left
  |   |   `-bash,4559 /home/prayag/tmux-powerline/powerline.sh left
  |   |       `-bash,4667 /home/prayag/tmux-powerline/powerline.sh left
  |   |           `-bash,4678 /home/prayag/tmux-powerline/powerline.sh left
  |   |               `-bash,4681 /home/prayag/tmux-powerline/powerline.sh left
  |   |                   |-git,4682 ls-files --others --exclude-standard
  |   |                   `-wc,4683 -l
  |   |-sh,4684 -c ~/tmux-powerline/powerline.sh left
  |   |   `-bash,4685 /home/prayag/tmux-powerline/powerline.sh left
  |   |       `-bash,4793 /home/prayag/tmux-powerline/powerline.sh left
  |   |           `-bash,4804 /home/prayag/tmux-powerline/powerline.sh left
  |   |               `-bash,4807 /home/prayag/tmux-powerline/powerline.sh left
  |   |                   |-git,4808 ls-files --others --exclude-standard
  |   |                   `-wc,4809 -l
  |   |-sh,4810 -c ~/tmux-powerline/powerline.sh left
  |   |   `-bash,4811 /home/prayag/tmux-powerline/powerline.sh left
  |   |       `-bash,4919 /home/prayag/tmux-powerline/powerline.sh left
  |   |           `-bash,4930 /home/prayag/tmux-powerline/powerline.sh left
  |   |               `-bash,4933 /home/prayag/tmux-powerline/powerline.sh left
  |   |                   |-git,4934 ls-files --others --exclude-standard
  |   |                   `-wc,4935 -l
  |   |-sh,4936 -c ~/tmux-powerline/powerline.sh left
  |   |   `-bash,4937 /home/prayag/tmux-powerline/powerline.sh left
  |   |       `-bash,5045 /home/prayag/tmux-powerline/powerline.sh left
  |   |           `-bash,5056 /home/prayag/tmux-powerline/powerline.sh left
  |   |               `-bash,5059 /home/prayag/tmux-powerline/powerline.sh left
  |   |                   |-git,5060 ls-files --others --exclude-standard
  |   |                   `-wc,5061 -l
  |   |-sh,5062 -c ~/tmux-powerline/powerline.sh left
  |   |   `-bash,5063 /home/prayag/tmux-powerline/powerline.sh left
  |   |       `-bash,5171 /home/prayag/tmux-powerline/powerline.sh left
  |   |           `-bash,5182 /home/prayag/tmux-powerline/powerline.sh left
  |   |               `-bash,5185 /home/prayag/tmux-powerline/powerline.sh left
  |   |                   |-git,5186 ls-files --others --exclude-standard
  |   |                   `-wc,5187 -l
  |   |-sh,5188 -c ~/tmux-powerline/powerline.sh left
  |   |   `-bash,5189 /home/prayag/tmux-powerline/powerline.sh left
  |   |       `-bash,5297 /home/prayag/tmux-powerline/powerline.sh left
  |   |           `-bash,5308 /home/prayag/tmux-powerline/powerline.sh left
  |   |               `-bash,5311 /home/prayag/tmux-powerline/powerline.sh left
  |   |                   |-git,5312 ls-files --others --exclude-standard
  |   |                   `-wc,5313 -l
  |   |-sh,5358 -c ~/tmux-powerline/powerline.sh left
  |   |   `-bash,5359 /home/prayag/tmux-powerline/powerline.sh left
  |   |       `-bash,5467 /home/prayag/tmux-powerline/powerline.sh left
  |   |           `-bash,5478 /home/prayag/tmux-powerline/powerline.sh left
  |   |               `-bash,5481 /home/prayag/tmux-powerline/powerline.sh left
  |   |                   |-git,5482 ls-files --others --exclude-standard
  |   |                   `-wc,5483 -l
  |   |-sh,5489 -c ~/tmux-powerline/powerline.sh left
  |   |   `-bash,5490 /home/prayag/tmux-powerline/powerline.sh left
  |   |       `-bash,5598 /home/prayag/tmux-powerline/powerline.sh left
  |   |           `-bash,5609 /home/prayag/tmux-powerline/powerline.sh left
  |   |               `-bash,5612 /home/prayag/tmux-powerline/powerline.sh left
  |   |                   |-git,5613 ls-files --others --exclude-standard
  |   |                   `-wc,5614 -l

【问题讨论】:

    标签: linux git ubuntu process


    【解决方案1】:

    在这种情况下,pstree 可以帮助您确定流程的开始位置:

    pstree -apl
    

    将列出所有正在运行的进程及其父进程(=启动它的进程)。这应该可以帮助您弄清楚是什么启动了所有这些 git 进程。

    如果你已经弄清楚了,你可以看看如何阻止它们启动......

    【讨论】:

    • 喜欢命令$ pstree -apl。问题在于我在.bashrc 中设置为默认终端([[ $TERM != "screen" ]] && exec tmux -2)的tmux。从.bashrc 中删除它可以解决问题。会看的更远。感谢pstree
    猜你喜欢
    • 2022-01-17
    • 1970-01-01
    • 1970-01-01
    • 2016-04-18
    • 2020-03-27
    • 2011-04-17
    • 2023-01-03
    • 1970-01-01
    • 2012-02-18
    相关资源
    最近更新 更多