当前位置: 首页 > news >正文

vscode ssh-remote 疑似内存泄漏问题

vscode ssh-remote疑似内存泄漏问题

系统信息与版本号

版本:1.88.1(通用)
日期:2024-04-10T17:42:52.765Z
Electron: 28.2.8
ElectronBuildId: 27744544
Chromium:120.0.6099.291
Node.js:18.18.2
V8:12.0.267.19-electron.0
操作系统:Darwin x64 23.4.0

问题描述

vscodessh-remote 插件连接之后,会发现内存不断上涨,然后导致云主机崩溃。ubantu22.04与debian等系统均有这种情况。

疑似出现了内存泄漏,经过仔细检查发现vscode-server这个进程会不断添加新的进程进去,问题复现步骤:

  1. 使用 TypeScript 文件打开远程工作区
  2. 等待“正在初始化 JS/TS 语言功能”状态栏指示器停止出现。
  3. 运行此脚本以获取 ionotify 观察程序进程列表:脚本
  4. 请注意命令类似于 ~/.vscode-server/cli/servers/Stable-e170252f762678dec6ca2cc69aba1570769a5d39/server/node 的进程数量
  5. 重新加载窗口
  6. 重复步骤 2 到 4,你会发现步骤 4 中记下的数字比上次增加了。

脚本

#!/bin/bash# Get the procs sorted by the number of inotify watches
# @author Carl-Erik Kopseng
# @latest https://github.com/fatso83/dotfiles/blob/master/utils/scripts/inotify-consumers
# Discussion leading up to answer: https://unix.stackexchange.com/questions/15509/whos-consuming-my-inotify-resources
#
# If you need ultimate speed, use https://github.com/fatso83/dotfiles/commit/inotify-consumers-v1-fastest
# # Speed enhancements by Simon Matter <simon.matter@invoca.ch>
#
# A later PR introduced a significant slowdown to gain better output, but it is insignificant on most machines
# See this for details: https://github.com/fatso83/dotfiles/pull/10#issuecomment-1122374716main(){# get terminal widthdeclare -i COLS=$(tput cols 2>/dev/null || echo 80)declare -i WLEN=10printf "\n%${WLEN}s  %${WLEN}s\n" "INOTIFY" "INSTANCES"printf "%${WLEN}s  %${WLEN}s\n" "WATCHES" "PER   "printf "%${WLEN}s  %${WLEN}s  %s\n" " COUNT " "PROCESS "    "PID USER         COMMAND"printf -- "------------------------------------------------------------\n"generateData
}usage(){cat << EOF
Usage: $0 [--help|--limits]-l, --limits    Will print the current related limits and how to change them-h, --help      Show this help
EOF
}limits(){printf "\nCurrent limits\n-------------\n"sysctl fs.inotify.max_user_instances fs.inotify.max_user_watchescat <<- EOF
Changing settings permanently
-----------------------------
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf
sudo sysctl -p # re-read config
EOF
}if [ "$1" = "--limits" -o "$1" = "-l" ]; thenlimitsexit 0
fiif [ "$1" = "--help" -o "$1" = "-h" ]; thenusageexit 0
fiif [ -n "$1" ]; thenprintf "\nUnknown parameter '$1'\n" >&2usageexit 1
figenerateData(){local -i PROClocal -i PIDlocal -i CNTlocal -i INSTANCESlocal -i TOTlocal -i TOTINSTANCES# read process list into cachelocal PSLIST="$(ps ax -o pid,user=WIDE-COLUMN,command --columns $(( COLS - WLEN )))"local INOTIFY="$(find /proc/[0-9]*/fdinfo -type f 2>/dev/null | xargs grep ^inotify 2>/dev/null)"local INOTIFYCNT="$(echo "$INOTIFY" | cut -d "/" -s --output-delimiter=" "  -f 3 |uniq -c | sed -e 's/:.*//')"# unique instances per process is denoted by number of inotify FDslocal INOTIFYINSTANCES="$(echo "$INOTIFY" | cut -d "/" -s --output-delimiter=" "   -f 3,5 | sed -e 's/:.*//'| uniq |awk '{print $1}' |uniq -c)"local INOTIFYUSERINSTANCES="$(echo "$INOTIFY" | cut -d "/" -s --output-delimiter=" "   -f 3,5 | sed -e 's/:.*//' | uniq |while read PID FD; do echo $PID $FD $(grep -e "^\ *${PID}\ " <<< "$PSLIST"|awk '{print $2}'); done | cut -d" "  -f 3 | sort | uniq -c |sort -nr)"set -ecat <<< "$INOTIFYCNT" |{while read -rs CNT PROC; do   # count watches of processes foundecho "${PROC},${CNT},$(echo "$INOTIFYINSTANCES" | grep " ${PROC}$" |awk '{print $1}')"done} |grep -v ",0," |                  # remove entires without watchessort -n -t "," -k 2,3 -r |         # sort to begin with highest numbers{                                # group commands so that $TOT is visible in the printfIFS=","while read -rs PID CNT INSTANCES; do   # show watches and corresponding process infoprintf "%$(( WLEN - 2 ))d  %$(( WLEN - 2 ))d     %s\n" "$CNT" "$INSTANCES" "$(grep -e "^\ *${PID}\ " <<< "$PSLIST")"TOT=$(( TOT + CNT ))TOTINSTANCES=$(( TOTINSTANCES + INSTANCES))done# These stats should be per-user as well, since inotify limits are per-user..printf "\n%$(( WLEN - 2 ))d  %s\n" "$TOT" "WATCHES TOTAL COUNT"
# the total across different users is somewhat meaningless, not printing for now.
#            printf "\n%$(( WLEN - 2 ))d  %s\n" "$TOTINSTANCES" "TOTAL INSTANCES COUNT"}echo ""echo "INotify instances per user (e.g. limits specified by fs.inotify.max_user_instances): "echo ""(echo "INSTANCES    USER"echo "-----------  ------------------"echo "$INOTIFYUSERINSTANCES") | column -techo ""}main

原问题网址

简单来描述这个问题,就是每次使用ssh-remote连接之后,会出现一个问题:

~/.vscode-server/cli/servers/Stable-…这个进程的数量增加了

当你关闭连接后,这个进程不会消失,但是下一次打开连接后,会产生新的进程,这样的结果就是导致进程数量不断增加导致占用的内存越来越多,最后导致系统崩溃重启。

修复方式

vscode 更新到预发布版本,开发者已经在最新的预发布版本中解决了这个问题。

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • 两轮电动车行业竞争激烈,九号公司如何破局
  • uniapp点击图片预览,关闭预览图片后自动触发onshow生命周期,怎么解决?
  • Windows 环境使用 Docker 安装 ES Kibana 8.12.2 及analysis-ik插件
  • 【黑马】MyBatis
  • pythonUI自动化008::allure测试报告(安装及应用)
  • sed命令笔记
  • 基于SpringBoot+Vue校园失物招领系统的设计与实现
  • 【将Python程序打包成一个可执行文件】
  • Spring Data JPA 自动创建时间的相关注解和用法
  • vue前后端交互学习问题记录2
  • LeetCode 第二十三天 2024.8.9
  • NPM使用教程
  • Halcon玩转机器视觉专栏特殊声明
  • springboot 实现阿里云点播系统使用凭证播放
  • JS 逆向高阶之 - nodejs 常用的几个加密, 解密的库
  • 收藏网友的 源程序下载网
  • DataBase in Android
  • el-input获取焦点 input输入框为空时高亮 el-input值非法时
  • Perseus-BERT——业内性能极致优化的BERT训练方案
  • PHP那些事儿
  • PV统计优化设计
  • python学习笔记-类对象的信息
  • SOFAMosn配置模型
  • vagrant 添加本地 box 安装 laravel homestead
  • 阿里中间件开源组件:Sentinel 0.2.0正式发布
  • 分布式熔断降级平台aegis
  • 分布式事物理论与实践
  • 排序算法之--选择排序
  • 入职第二天:使用koa搭建node server是种怎样的体验
  • 通过npm或yarn自动生成vue组件
  • 网页视频流m3u8/ts视频下载
  • 小试R空间处理新库sf
  • 以太坊客户端Geth命令参数详解
  • 再次简单明了总结flex布局,一看就懂...
  • raise 与 raise ... from 的区别
  • 浅谈sql中的in与not in,exists与not exists的区别
  • ​ 全球云科技基础设施:亚马逊云科技的海外服务器网络如何演进
  • ​iOS实时查看App运行日志
  • ​批处理文件中的errorlevel用法
  • ​一帧图像的Android之旅 :应用的首个绘制请求
  • # 日期待t_最值得等的SUV奥迪Q9:空间比MPV还大,或搭4.0T,香
  • # 睡眠3秒_床上这样睡觉的人,睡眠质量多半不好
  • # 透过事物看本质的能力怎么培养?
  • #100天计划# 2013年9月29日
  • (1)Nginx简介和安装教程
  • (7) cmake 编译C++程序(二)
  • (C语言)球球大作战
  • (笔记)M1使用hombrew安装qemu
  • (二)【Jmeter】专栏实战项目靶场drupal部署
  • (六)DockerCompose安装与配置
  • .gitignore文件使用
  • .NET Core Web APi类库如何内嵌运行?
  • .Net MVC4 上传大文件,并保存表单
  • .NET 快速重构概要1
  • .NET 设计一套高性能的弱事件机制