首页 > 系统相关 >selenium 未即时关闭引起的内存泄漏 差点死机

selenium 未即时关闭引起的内存泄漏 差点死机

时间:2024-04-30 10:33:59浏览次数:16  
标签:remote -- 死机 zhangshan selenium 20 内存 firefox usr

selenium webdriver firefox 测试自动登录获取 token,测试可以达到目的。然后日常摸鱼后发现浏览器快卡死了,切tty看top,任务没跑多少,内存倒是快榨干了,这不合理,也没有跑什么大内存程序,先把bt、sync给kill了,内存情况也没有太好转,于是看下内存占用,然后找内存占用高的进程,把这些占用高的给kill掉,内存占用就下来了。然后发现都是 firefox 相关的,然后此时我早已关闭了浏览器,然后考虑到之前用 selenium 跑测试来着,因此大概率是没正常释放资源,一看代码确实 quit 不一定执行,比如说中间发生异常,就不会执行quit,于是try except finally 补丁。奇怪的是,印象里程序异常退出、资源就释放掉了,比如父子进程

  • top 看在跑的进程数量、进程的 cpu 占用、内存占用,按 m 可以看内存占用的条形图
  • free -g 可以看内存总量、剩余量,-g 表示单位是 GB
  • ps -aux | sort -k4nr | head -10 查看内存占用前十的进程。ps 用于查看当前系统的进程状态, sort对输入的内容进行排序,-k4 指定以第四列的数值作为排序的键,按 -k4nr 表示按照第 4 列的数值进行降序排列,查看占用内存最多的进程
$ top -b | head -15
top - 11:49:40 up 9 days, 30 min,  2 users,  load average: 8.29, 48.25, 32.03
任务: 424 total,   2 running, 421 sleeping,   0 stopped,   1 zombie
%Cpu(s):  3.8 us,  6.4 sy,  0.0 ni, 89.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st 
MiB Mem :  15270.4 total,   1092.5 free,  12969.7 used,   3985.7 buff/cache     
MiB Swap:      0.0 total,      0.0 free,      0.0 used.   2300.8 avail Mem 

 进程号 USER      PR  NI    VIRT    RES    SHR    %CPU  %MEM     TIME+ COMMAND
 356300 zhang shan     20   0   15484   6000   3696 R  23.1   0.0   0:00.06 top
 280353 root      20   0  181792  21336   4080 S  15.4   0.1   0:21.84 dirmngr
  33103 zhangshan     20   0 2547336  36488   2244 S   7.7   0.2 141:24.28 WebExte+
  35611 zhangshan     20   0 2547336  32864   2584 S   7.7   0.2 143:03.09 WebExte+
 308391 zhangshan     20   0 3029928 210272  17160 S   7.7   1.3   9:40.32 firefox
      1 root      20   0   22444   8900   5304 S   0.0   0.1   0:15.02 systemd
      2 root      20   0       0      0      0 S   0.0   0.0   0:00.13 kthreadd
      3 root      20   0       0      0      0 S   0.0   0.0   0:00.00 pool_wo+

$ free -g
               total        used        free      shared  buff/cache   available
内存:            14          12           1           2           3           2
交换:             0           0           0
$ ps -aux | sort -k4nr | head -10
zhangshan      35505  0.9  1.7 3044476 269632 ?      Sl   4月20 117:21 /usr/lib/firefox/firefox --marionette --headless --remote-debugging-port 55663 --remote-allow-hosts localhost -no-remote -profile /tmp/rust_mozprofileYUuCMy
zhangshan      31216  0.9  1.6 3045484 257948 ?      Sl   4月20 119:45 /usr/lib/firefox/firefox --marionette --headless --remote-debugging-port 40957 --remote-allow-hosts localhost -no-remote -profile /tmp/rust_mozprofileQkLA3z
zhangshan      31697  0.9  1.6 3046036 256520 ?      Sl   4月20 115:40 /usr/lib/firefox/firefox --marionette --headless --remote-debugging-port 48411 --remote-allow-hosts localhost -no-remote -profile /tmp/rust_mozprofile6gxPMw
zhangshan      32516  0.8  1.6 3036764 254252 ?      Sl   4月20 112:57 /usr/lib/firefox/firefox --marionette --headless --remote-debugging-port 55389 --remote-allow-hosts localhost -no-remote -profile /tmp/rust_mozprofileKmaAFn
zhangshan      33538  0.9  1.6 3071120 253928 ?      Sl   4月20 116:45 /usr/lib/firefox/firefox --marionette --headless --remote-debugging-port 44327 --remote-allow-hosts localhost -no-remote -profile /tmp/rust_mozprofileqxHGiz
zhangshan      32997  0.9  1.5 2969196 236076 ?      Sl   4月20 113:59 /usr/lib/firefox/firefox --marionette --headless --remote-debugging-port 33505 --remote-allow-hosts localhost -no-remote -profile /tmp/rust_mozprofileGBP2p7
zhangshan     306446  0.8  1.3 2969684 209232 ?      Sl   4月28   9:29 /usr/lib/firefox/firefox --marionette --headless --remote-debugging-port 60987 --remote-allow-hosts localhost -no-remote -profile /tmp/rust_mozprofileWojSCe
zhangshan     308391  0.8  1.3 3029928 210272 ?      Sl   4月28   9:40 /usr/lib/firefox/firefox --marionette --headless --remote-debugging-port 45885 --remote-allow-hosts localhost -no-remote -profile /tmp/rust_mozprofilexxB0wC
zhangshan     310041  0.8  1.3 2976120 217360 ?      Sl   4月28   9:35 /usr/lib/firefox/firefox --marionette --headless --remote-debugging-port 57229 --remote-allow-hosts localhost -no-remote -profile /tmp/rust_mozprofile1bynOt
zhangshan     311240  0.8  1.3 2974576 209136 ?      Sl   4月28   9:50 /usr/lib/firefox/firefox --marionette --headless --remote-debugging-port 40533 --remote-allow-hosts localhost -no-remote -profile /tmp/rust_mozprofile0cG0ul
$ kill 35505 31216 31697 32516 33538 32997 306446

$ ps -aux | sort -k4nr | head -10
zhangshan     316113  0.8  1.2 2966888 195944 ?      Sl   4月28   9:18 /usr/lib/firefox/firefox --marionette --headless --remote-debugging-port 51917 --remote-allow-hosts localhost -no-remote -profile /tmp/rust_mozprofileY1JSG1
zhangshan     335124  1.0  1.2 3025232 188836 ?      Sl   09:03   1:43 /usr/lib/firefox/firefox --marionette --headless --remote-debugging-port 38679 --remote-allow-hosts localhost -no-remote -profile /tmp/rust_mozprofile9rOJME
zhangshan     335620  1.1  1.0 2981756 157876 ?      Sl   09:04   1:59 /usr/lib/firefox/firefox --marionette --headless --remote-debugging-port 48943 --remote-allow-hosts localhost -no-remote -profile /tmp/rust_mozprofiletfvn8Y
zhangshan       1244  0.0  0.6 586220 94128 ?        Sl   4月20   5:34 /usr/bin/fcitx5
root         523  3.6  0.6 916988 101208 tty7    Ssl+ 4月20 479:46 /usr/lib/Xorg :0 -seat seat0 -auth /run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
zhangshan     336749  0.1  0.5 2728544 84420 ?       Sl   09:04   0:15 /usr/lib/firefox/firefox -contentproc -childID 3 -isForBrowser -prefsLen 28477 -prefMapSize 241150 -jsInitLen 234952 -parentBuildID 20240416221418 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appDir /usr/lib/firefox/browser {3ca94547-d8eb-4d3f-a3e5-cc863397af7a} 335620 true tab
zhangshan       1219  0.0  0.4 586368 72796 ?        Sl   4月20   0:43 xfdesktop
zhangshan     335345  0.0  0.4 2713192 77140 ?       Sl   09:03   0:03 /usr/lib/firefox/firefox -contentproc -childID 3 -isForBrowser -prefsLen 28629 -prefMapSize 241150 -jsInitLen 234952 -parentBuildID 20240416221418 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appDir /usr/lib/firefox/browser {bf8e4007-45c1-46b9-9f14-fd8f9856f0d5} 335124 true tab
root         488  1.2  0.4 2507020 73324 ?       Ssl  4月20 160:03 /usr/bin/opensnitchd -rules-path /etc/opensnitchd/rules
zhangshan       1148  1.1  0.3 1021576 54492 ?       Sl   4月20 148:07 xfwm4
$ kill 316113 335124 335620
$ ps -aux | sort -k4nr | head -10
zhangshan       1244  0.0  0.6 586220 94128 ?        Sl   4月20   5:34 /usr/bin/fcitx5
root         523  3.6  0.6 917300 101464 tty7    Ssl+ 4月20 479:46 /usr/lib/Xorg :0 -seat seat0 -auth /run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
zhangshan       1219  0.0  0.4 586368 72796 ?        Sl   4月20   0:43 xfdesktop
root         488  1.2  0.4 2507020 73708 ?       Ssl  4月20 160:04 /usr/bin/opensnitchd -rules-path /etc/opensnitchd/rules
zhangshan       1148  1.1  0.3 1021576 54492 ?       Sl   4月20 148:07 xfwm4
zhangshan       1207  0.0  0.3 1022016 54500 ?       Sl   4月20   3:59 xfce4-panel
zhangshan     355237  1.5  0.3 629832 59440 ?        Sl   11:47   0:03 /usr/bin/xfce4-terminal
root         223  0.0  0.3 165244 57048 ?        Ss   4月20   1:47 /usr/lib/systemd/systemd-journald
root         640  0.0  0.3 2708056 54740 ?       Ssl  4月20   4:51 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
$ free -g
               total        used        free      shared  buff/cache   available
内存:            14           3          10           1           3          11
交换:             0           0           0

标签:remote,--,死机,zhangshan,selenium,20,内存,firefox,usr
From: https://www.cnblogs.com/guilinmifen/p/18167374

相关文章

  • JVM内存管理
    在JVM初识中提到之所以在程序和操作系统之间增加JVM,就是JVM有些内存管理的特性直接在操作系统上实现有些费劲。那么JVM的内存管理是怎样的呢?应用程序运行大致如下过程: 其中内存部分就是运......
  • linux安装selenium步骤
    1,安装selenium模块pip3installselenium2,安装谷歌浏览器yuminstallhttps://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm-y3安装chromedriver1)运行下面命令查看浏览器版本google-chrome--version 出现这个代表谷歌浏览器安装成功2)谷歌......
  • 微服务体系-docker容器cpu内存管理
    在微服务体系中,我们使用docker去部署微服务,在服务器资源有限的情况下。由于某个的服务(docker容器)cpu使用过高,或者内存使用过高会导致整个的服务器的崩溃。针对这个问题,我采取了以下措施:在dockerrun命令中添加--cpus=2--memory=4g --cpus=2:设置cpu最多使用2个核心数......
  • openGauss MOT本地内存和全局内存
    MOT本地内存和全局内存SILO管理本地内存和全局内存,如所示。全局内存是所有核共享的长期内存,主要用于存储所有的表数据和索引。本地内存是短期内存,主要由会话使用,用于处理事务及将数据更改存储到事务内存中,直到提交阶段。当事务需要更改时,SILO将该事务的所有数据从全局内存复......
  • openGauss MOT本地内存和全局内存
    MOT本地内存和全局内存SILO管理本地内存和全局内存,如所示。全局内存是所有核共享的长期内存,主要用于存储所有的表数据和索引。本地内存是短期内存,主要由会话使用,用于处理事务及将数据更改存储到事务内存中,直到提交阶段。当事务需要更改时,SILO将该事务的所有数据从全局内存复......
  • openGauss MOT内存管理
    MOT内存管理规划和微调请参见MOT内存和存储规划和MOT配置。详情查看:https://opengauss.org详情查看:https://docs-opengauss.osinfra.cn......
  • openGauss MOT内存和存储规划
    MOT内存和存储规划本节描述了为满足特定应用程序需求,在评估、估计和规划内存和存储容量数量时,需要注意的事项和准则,以及影响所需内存数量的各种数据,例如计划表的数据和索引大小、维持事务管理的内存以及数据增长的速度。MOT内存规划MOT是一种内存数据库存储引擎(IMDB),其中所有表......
  • Dell R720 内存纠错比率超限 更换内存引起的故障
    DellR720内存纠错比率超限更换内存引起的故障2019年12月18日 8823点热度 27人点赞 0条评论0x01前言服务器里有一根内存出现异常,在除错的过程中我详细了解R720的内存配置。我在这里将除错过程和基本配置信息记录下来。0x02错误在上周,我发现服务器后部的状态灯不再......
  • C#内存管理
    前言在职场中,确立自身的技术水平很重要,因为,如果你被标记成了技术菜鸟,那么你的工作一旦做快了,大家就会一致的认为这个任务比较简单;如果你未如期完成,则会被各种明嘲暗讽,你不但无法获得合理的表扬,还会无端被迫接受攻击。但是,如果你被标记成了技术高手,那么你就算任务延期也会被理解,......
  • 如何准确的估计llm推理和微调的内存消耗
    Command-R+,Mixtral-8x22b和Llama370b都在最近的几周内发布了,这些模型是巨大的。它们都有超过700亿个参数:Command-R+:104B参数Mixtral-8x22b:具有141B参数的混合专家(MoE)模型Llama370b:70.6B参数你能在电脑上微调和运行这些模型吗?在本文中,我将介绍如何计算这些模型用......