<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      .net core在linux docker部署,內存異常分析,分析工具:dotnet-dump

      老項目為.net 4.6,部署在iis,設置的32位,消耗內存基本穩定在500mb左右,但是升級為.net 6,部署在linux docker上以后,內存消耗異常,記錄一下

      docker stats查看, 用戶模塊占10g

      一,創建dump文件

      注:執行/usr/share/dotnet/shared/Microsoft.NETCore.App/6.0.25/createdump 1 這句的時候,會導致程序無法訪問,內存越大,保存時間越長,請選擇合適的時間進行此操作。

      [root@WEB1 zwsec]# docker exec -it base bash
      root@68a12d966fa4:/src# find / -name createdump
      /usr/share/dotnet/shared/Microsoft.NETCore.App/6.0.25/createdump
      root@68a12d966fa4:/src# /usr/share/dotnet/shared/Microsoft.NETCore.App/6.0.25/createdump 1
      [createdump] Gathering state for process 1 dotnet
      [createdump] Writing minidump with heap to file /tmp/coredump.1
      [createdump] Written 13254832128 bytes (3236043 pages) to core file
      [createdump] Target process is alive
      [createdump] Dump successfully written
      root@68a12d966fa4:/src# exit
      exit
      [root@WEB1 zwsec]# docker cp base:/tmp/coredump.1 /data1/app/server/test_dump/coredump.1
      [root@WEB1 zwsec]# cd /data1/app/server/test_dump/
      [root@WEB1 test_dump]# ls
      coredump.1

       

      二、分析dump文件


      dotnet-dump工具依賴dotnet的sdk,如果宿主機中安裝了sdk可以直接在宿主機中分析;
      如果不想污染宿主機環境可以拉取一個sdk鏡像mcr.microsoft.com/dotnet/sdk,創建一個臨時環境用于分析。

      1,創建一個用于分析的臨時容器

      需要把用于存放coredump.1文件的目錄掛載到容器,或者自己cp進去。
      創建好容器之后需要安裝dotnet-dump工具

      docker run  --security-opt seccomp=unconfined --name test --rm -it -v /data1/app/server/test_dump:/tmp/coredump mcr.microsoft.com/dotnet/sdk 
      注:需要加上 --security-opt seccomp=unconfined 否則安裝dotnet-dump時可能報錯
       

      [root@WEB1 zwsec]# docker run --security-opt seccomp=unconfined --name test --rm -it -v /data1/app/server/test_dump:/tmp/coredump mcr.microsoft.com/dotnet/sdk
      Unable to find image 'mcr.microsoft.com/dotnet/sdk:latest' locally
      latest: Pulling from dotnet/sdk
      fd674058ff8f: Pull complete
      d92ceca2d7b5: Pull complete
      408b46bb4d4d: Pull complete
      e9dfe0944a0c: Pull complete
      3425c4117635: Pull complete
      e4513f6c2cfb: Pull complete
      5e118823fce1: Pull complete
      66fb1dfc2c9d: Pull complete
      683a16faa7de: Pull complete
      Digest: sha256:3fcf6f1e809c0553f9feb222369f58749af314af6f063f389cbd2f913b4ad556
      Status: Downloaded newer image for mcr.microsoft.com/dotnet/sdk:latest
      root@d99cf52da4ed:/# cd /tmp/coredump
      root@d99cf52da4ed:/tmp/coredump# ls
      coredump.1
      root@d99cf52da4ed:/tmp/coredump# dotnet tool install -g dotnet-dump
      Tools directory '/root/.dotnet/tools' is not currently on the PATH environment variable.
      If you are using bash, you can add it to your profile by running the following command:

      cat << \EOF >> ~/.bash_profile
      # Add .NET Core SDK tools
      export PATH="$PATH:/root/.dotnet/tools"
      EOF

      You can add it to the current session by running the following command:

      export PATH="$PATH:/root/.dotnet/tools"

      You can invoke the tool using the following command: dotnet-dump
      Tool 'dotnet-dump' (version '9.0.553101') was successfully installed.
      root@d99cf52da4ed:/tmp/coredump# export PATH="$PATH:/root/.dotnet/tools"
      root@d99cf52da4ed:/tmp/coredump#

       

      2,分析內存泄漏

      命令:

      1.dotnet-dump analyze  coredump.1

      2.dumpheap -stat  找到堆上的對象信息(注:此命令第一次執行時會消耗很久時間,請泡一杯茶耐心等候,如果服務器會自動斷開連接的,建議下載到一臺不會斷開連接的機器進行分析,因為這里可能在沒有分析出來連接就斷開了)

      3.dumpheap -mt  <mt> 列出所有與<mt>結構對應的對象,一般我都會找string對象的mt,看看里面大size的string對象是有哪些

      4.do  <address> 查看對象詳細信息

      5.gcroot -all <address> 一般我也是找string地址,看看對象引用

       

       第1,2個命令結果:(請耐心等待,如果文件很大,請使用一臺靠譜的機器分析)

      root@d99cf52da4ed:/tmp/coredump# dotnet-dump analyze coredump.1
      Loading core dump: coredump.1 ...
      Ready to process analysis commands. Type 'help' to list available commands or 'help [command]' to get detailed help on a command.
      Type 'quit' or 'exit' to exit the session.
      > dumpheap -stat

       Statistics: MT Count TotalSize Class Name
      …………

      7f19789cbdd0 808,824 71,176,512 System.RuntimeMethodInfoStub
      7f197e149d88 758,432 78,876,928 Newtonsoft.Json.Linq.JProperty
      7f197cffb878 7,107,012 170,568,288 System.WeakReference<Microsoft.Extensions.DependencyInjection.ServiceProvider>
      7f1977244ab8 350,296 179,511,302 System.Char[]
      7f19789f5598 1,818,443 307,396,110 System.Byte[]
      7f197d74f1f0 325,913 433,410,924 <unknown_type_7f197d74f1f0>
      7f19771bd2e0 4,481,237 626,510,840 System.String
      563ee4af1ea0 497,037 1,051,396,144 Free
      Total 33,543,157 objects, 4,234,311,341 bytes

       此時我們看到一個很大的string,使用第三個命令:dumpheap -mt  {上面紅框第一個值}   注:這一步第一次執行的時候也會需要點時間,請耐心等待

      由于結果太多,沒有截到標題,第一列是address,最后一列是size

       

       

      結果出來了,可以看到有很多占內存一樣大的字符串,此時需要用到第四個命令  do {第一列的address}

       注:如果是比較小的string,紅框部分就會顯示該string的內容,但是這個太大了,無法顯示

      此時百度,谷歌,bing都查詢無果,然后敲下了每個軟件都會有的一個命令  help

       在所有命令中一個命令一個命令試過之后,找到兩個命令 dq <address>    du <address>
      先執行dq <address> ,會得到一群類似adress的東西

       再du <adress> 注:這里的address就用上面的結果(每個都試下,因為不是每一個都有你想要的結果)

      其中一個結果如下:

       這樣的數據結構,就可以找到接口了,暫時到這,下次再續。

       

      參考資料:
      http://www.rzrgm.cn/wu_u/p/14109333.html
      http://www.rzrgm.cn/TeemoHQ/p/15710523.html
      posted @ 2025-01-10 14:38  光頭漢  閱讀(598)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 美女胸18下看禁止免费视频| 欧美成人精品一区二区三区免费| 久久人人妻人人做人人爽| 91色老久久精品偷偷性色| 国产不卡一区二区四区| 性欧美丰满熟妇xxxx性| 精品久久综合日本久久网| 中国女人熟毛茸茸A毛片| 汤原县| 老司机亚洲精品一区二区| 亚洲一区二区精品偷拍| 国产永久免费高清在线| 国产午夜精品视频在线播放 | 长腿校花无力呻吟娇喘| 亚洲av区一区二区三区| 国产精成人品| 一本色道久久—综合亚洲| 高潮潮喷奶水飞溅视频无码| 南溪县| a级免费视频| 中文字幕日韩一区二区不卡| 亚洲欧美高清在线精品一区二区| 男人的天堂av一二三区| 中文字幕日韩一区二区不卡| 人妻少妇偷人无码视频| 久久精品国产亚洲av成人| 99热精国产这里只有精品| 亚洲欧美激情在线一区| 文昌市| gogogo高清在线观看视频中文| 日本熟妇XXXX潮喷视频| 亚洲精品无码日韩国产不卡av| 亚洲美女少妇偷拍萌白酱| 国产精品 无码专区| 久久亚洲精品11p| 国产一级老熟女自拍视频| 精品人妻少妇一区二区三区| 97亚洲熟妇自偷自拍另类图片| 九九热在线免费观看视频| 无码av最新无码av专区| 成人小说亚洲一区二区三区|