Code Helper佔用大量CPU和內存

項目架構:html

  React+TS+DVAnode

設備及軟件:git

   設備:Mac github

   軟件:VSCodejson

場景:瀏覽器

  在Mac中使用VSCode運行時發現項目編譯很是卡頓,時間長達五六分鐘以上,而且項目啓動後訪問頁面,頁面也會有明顯的卡頓。架構

初步檢查:svn

  打開活動監視器發現Code Helper啓動了好幾個,而且長時間佔用很是高的CPU及內存(CPU超過100%,1個Code Helper進程佔用1個多G內存)優化

解決方案:ui

  將如下代碼插入到VSCode的setting.json中去,並退出從新啓動VSCode和項目

"search.followSymlinks": false
 "files.exclude": { "**/.git": true, "**/.svn": true, "**/.hg": true, "**/CVS": true, "**/.DS_Store": true, "**/tmp": true, "**/node_modules": true, "**/bower_components": true, "**/dist": true }, "files.watcherExclude": { "**/.git/objects/**": true, "**/.git/subtree-cache/**": true, "**/node_modules/**": true, "**/tmp/**": true, "**/bower_components/**": true, "**/dist/**": true }

解決結果:

   1.CPU和內存佔用大量降低,內存會降到一個Code Helper進程佔用200多M。

   2.編譯時間小幅度縮減

   3.運行項目後,瀏覽器頁面卡頓感明顯消失

  (下圖爲優化後的內存佔用)

  

 

 

 引起緣由:

  如下緣由爲去gitGub上看了下VSCode出現這個問題的討論總結 

  1.由某些插件引起的問題,能夠嘗試禁用全部的VSCode插件再次嘗試

    2.因爲TS引用某些包或者插件致使

    我的更傾向於第二種緣由,由於其餘項目並無出現這個問題,只有兩個用了TS的項目出現這個問題,編譯巨慢,頁面卡頓,具體內部原理未知,待解決

    能夠去gitHub上看下關於這個問題的一些討論

    https://github.com/Microsoft/vscode/issues/11963
    https://github.com/microsoft/vscode/issues/11096#issuecomment-274879938
    https://github.com/microsoft/vscode/issues/51776

  

原文出處:https://www.cnblogs.com/suihang/p/11946434.html

相關文章
相關標籤/搜索