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

阳谷网站开发西安做网站哪家公司好

阳谷网站开发,西安做网站哪家公司好,网站推广员招聘,深圳做网站的大公司文章目录 源码Runtime.getRuntime()/proc/self/status/proc/meminfo 附总结 获取内存的指标有很多#xff0c;假如我们要写一个用于监控APP内存泄漏的框架的话#xff0c;主要获取哪些指标呢#xff1f; 这篇文章来研究下KOOM里面获取到是哪些指标。 下面正文开始#xff… 文章目录 源码Runtime.getRuntime()/proc/self/status/proc/meminfo 附总结 获取内存的指标有很多假如我们要写一个用于监控APP内存泄漏的框架的话主要获取哪些指标呢 这篇文章来研究下KOOM里面获取到是哪些指标。 下面正文开始 源码 File(/proc/self/status).forEachLineQuietly { line -if (procStatus.vssInKb ! 0 procStatus.rssInKb ! 0 procStatus.thread ! 0) returnforEachLineQuietlywhen {line.startsWith(VmSize) - {procStatus.vssInKb VSS_REGEX.matchValue(line)}line.startsWith(VmRSS) - {procStatus.rssInKb RSS_REGEX.matchValue(line)}line.startsWith(Threads) - {procStatus.thread THREADS_REGEX.matchValue(line)}}}File(/proc/meminfo).forEachLineQuietly { line -when {line.startsWith(MemTotal) - {memInfo.totalInKb MEM_TOTAL_REGEX.matchValue(line)}line.startsWith(MemFree) - {memInfo.freeInKb MEM_FREE_REGEX.matchValue(line)}line.startsWith(MemAvailable) - {memInfo.availableInKb MEM_AVA_REGEX.matchValue(line)}line.startsWith(CmaTotal) - {memInfo.cmaTotal MEM_CMA_REGEX.matchValue(line)}/*** IONHeap 是 Android 系统中用于内存管理的一种机制特别是在图形缓冲区和其他需要高效物理内存分配和映射的场合。ION (I/O Non-Contiguous Memory Allocator)* 是一个跨内核与用户空间设计的内存管理器它支持多种类型的内存分配包括但不限于系统堆system heap、连续内存块contiguous memory以及从特定预留区域分配的内存carveout heap。* 在Android系统中ION通过统一接口处理各种类型的内存分配允许更灵活地满足不同硬件组件如GPU、摄像头、显示子系统等对内存的需求同时优化内存使用效率减少碎片并且支持高效的DMA操作。* 上述代码片段是Kotlin程序的一部分其中memInfo.IONHeap是用来存储从日志或者其他文本信息中解析出来的ION内存相关信息的变量。当检测到某一行字符串以ION_heap开头时说明这一行可能包含* ION堆的内存使用量数据于是调用正则表达式MEM_ION_REGEX来提取出具体的内存值并将其存储在memInfo.IONHeap中。*/line.startsWith(ION_heap) - {memInfo.IONHeap MEM_ION_REGEX.matchValue(line)}}}memInfo.rate 1.0f * memInfo.availableInKb / memInfo.totalInKbMonitorLog.i(TAG, ----OOM Monitor Memory----)MonitorLog.i(TAG, [java] max:${javaHeap.max} used ratio:${(javaHeap.rate * 100).toInt()}%)MonitorLog.i(TAG,[proc] VmSize:${procStatus.vssInKb}kB VmRss:${procStatus.rssInKb}kB Threads:${procStatus.thread})MonitorLog.i(TAG,[meminfo] MemTotal:${memInfo.totalInKb}kB MemFree:${memInfo.freeInKb}kB MemAvailable:${memInfo.availableInKb}kB)MonitorLog.i(TAG,avaliable ratio:${(memInfo.rate * 100).toInt()}% CmaTotal:${memInfo.cmaTotal}kB ION_heap:${memInfo.IONHeap}kB)}这里直接copy这部分的源码出来可以看到里面只拿到了几个指标。为什么拿到的是这些指标呢我们通过命令行拿到对应的数据研究下。 Runtime.getRuntime() javaHeap.max Runtime.getRuntime().maxMemory()javaHeap.total Runtime.getRuntime().totalMemory()javaHeap.free Runtime.getRuntime().freeMemory()通过运行时获取到Java虚拟机堆的信息。 /proc/self/status 首先拿到进程对应的pid。 PS C:\Users\LinShujie adb shell ps | grep koom PS C:\Users\LinShujie adb shell ps | grep koom u0_a50 2888 1362 3219764 95460 0 0 S com.kwai.koom.demo手动触发memory leak前 PS C:\Users\LinShujie adb shell cat /proc/2888/status Name: .kwai.koom.demo State: S (sleeping) Tgid: 2888 Ngid: 0 Pid: 2888 PPid: 1362 TracerPid: 0 Uid: 10050 10050 10050 10050 Gid: 10050 10050 10050 10050 FDSize: 64 Groups: 9997 20050 50050 NStgid: 2888 NSpid: 2888 NSpgid: 1362 NSsid: 0 VmPeak: 3580660 kB VmSize: 3219892 kB VmLck: 0 kB VmPin: 0 kB VmHWM: 95460 kB VmRSS: 95460 kB VmData: 2311600 kB VmStk: 8192 kB VmExe: 20 kB VmLib: 117940 kB VmPTE: 632 kB VmPMD: 24 kB VmSwap: 0 kB HugetlbPages: 0 kB Threads: 13 SigQ: 0/3957 SigPnd: 0000000000000000 ShdPnd: 0000000000000000 SigBlk: 0000000000001204 SigIgn: 0000000000000001 SigCgt: 00000006400084f8 CapInh: 0000000000000000 CapPrm: 0000000000000000 CapEff: 0000000000000000 CapBnd: 0000000000000000 CapAmb: 0000000000000000 Seccomp: 0Speculation_Store_Bypass: vulnerable Cpus_allowed: 3 Cpus_allowed_list: 0-1 voluntary_ctxt_switches: 197 nonvoluntary_ctxt_switches: 100手动触发memory leak后 PS C:\Users\LinShujie adb shell cat /proc/2888/status Name: .kwai.koom.demo State: S (sleeping) Tgid: 2888 Ngid: 0 Pid: 2888 PPid: 1362 TracerPid: 0 Uid: 10050 10050 10050 10050 Gid: 10050 10050 10050 10050 FDSize: 64 Groups: 9997 20050 50050 NStgid: 2888 NSpid: 2888 NSpgid: 1362 NSsid: 0 VmPeak: 4015804 kB VmSize: 4014224 kB VmLck: 0 kB VmPin: 0 kB VmHWM: 114012 kB VmRSS: 114004 kB VmData: 3093864 kB VmStk: 8192 kB VmExe: 20 kB VmLib: 119268 kB VmPTE: 2212 kB VmPMD: 28 kB VmSwap: 0 kB HugetlbPages: 0 kB Threads: 715 SigQ: 0/3957 SigPnd: 0000000000000000 ShdPnd: 0000000000000000 SigBlk: 0000000000001204 SigIgn: 0000000000000001 SigCgt: 00000006400084f8 CapInh: 0000000000000000 CapPrm: 0000000000000000 CapEff: 0000000000000000 CapBnd: 0000000000000000 CapAmb: 0000000000000000 Seccomp: 0Speculation_Store_Bypass: vulnerable Cpus_allowed: 3 Cpus_allowed_list: 0-1 voluntary_ctxt_switches: 1964 nonvoluntary_ctxt_switches: 229代码里面拿到的是VmSize、VmRSS、和线程数。 这里的VmSize和VmRss和Vss 、Rss是否为同一个指标 我们procrank命令来看下结果 1|star2qltechn:/ $ su :/ # procrankPID Vss Rss Pss Uss cmdline1529 3848968K 194612K 87827K 77496K system_server1673 3296392K 167556K 63256K 52388K com.android.systemui2888 3247024K 115544K 39744K 32996K com.kwai.koom.demo2176 3250116K 139600K 39249K 29464K com.android.launcher31859 3245816K 114868K 27183K 20520K com.android.settings1696 1386324K 46092K 23500K 12600K webview_zygote1843 3226548K 104512K 19487K 13796K com.android.phone2251 3612560K 107956K 19465K 10796K com.android.flysilkworm1659 3230128K 93368K 15295K 10788K com.android.bluetooth1363 1380040K 51524K 13215K 1048K zygote2298 3594528K 89688K 12022K 4932K com.android.flysilkworm:LdPushService2309 3183496K 84676K 11479K 7676K android.process.acore2466 3186916K 80976K 10735K 7396K com.android.messaging2164 3187012K 84496K 10149K 5936K android.process.media2349 3590068K 83284K 9305K 3456K com.android.flysilkworm:filedownloader1362 3497064K 94596K 8836K 2008K zygote642122 3201828K 78048K 8263K 4664K com.android.coreservice2403 3182732K 77792K 7110K 3452K com.android.inputmethod.pinyin2491 3182640K 68984K 7041K 4496K com.android.packageinstaller2550 3182916K 70348K 6993K 4352K com.android.traceur2516 3180036K 74636K 6848K 3764K com.android.providers.calendar2422 3179424K 68632K 6399K 3832K com.android.managedprovisioning2140 3180556K 69872K 6121K 3412K com.android.printspooler1907 3180500K 71608K 5962K 2968K android.ext.services1391 88240K 13488K 5378K 4684K /system/bin/surfaceflinger2108 3181736K 67684K 5261K 2648K com.android.se2848 3179104K 66600K 5177K 2600K com.android.keychain2198 3178328K 66728K 5140K 2456K com.android.smspush1389 58304K 10272K 5116K 4300K /system/bin/audioserver1406 66712K 10912K 5024K 3976K /system/bin/mediaserver1404 2169688K 15624K 4993K 3888K media.extractor1410 44792K 7780K 3718K 3252K media.codec1398 41808K 8316K 3220K 2440K /system/bin/cameraserver1405 2138768K 11496K 2899K 2164K media.metrics1306 19344K 5356K 2616K 2572K /system/bin/logd1399 28636K 6772K 2157K 1532K /system/bin/drmserver1361 32884K 7900K 2152K 1892K /system/bin/netd1379 66128K 7728K 2039K 1724K /vendor/bin/hw/android.hardware.graphics.composer2.1-service1377 36548K 6532K 1919K 1768K /vendor/bin/hw/android.hardware.gnss1.0-service1311 22268K 6924K 1889K 1752K /system/bin/vold2590 33372K 1964K 1867K 1860K /system/bin/adbd1 19188K 2996K 1845K 1468K /init1401 20044K 6152K 1842K 1732K /system/bin/installd1368 41692K 4932K 1839K 1452K /vendor/bin/hw/android.hardware.audio2.0-service1411 19168K 5320K 1758K 1696K /vendor/bin/hw/rild1371 38212K 5232K 1698K 1272K /vendor/bin/hw/android.hardware.camera.provider2.4-service1408 20764K 6244K 1646K 1464K /system/bin/storaged1387 17820K 5208K 1634K 1572K /vendor/bin/hw/android.hardware.wifi1.0-service1407 20448K 6136K 1495K 1380K /system/bin/statsd1409 19872K 6084K 1469K 1360K /system/bin/wificond1367 23308K 7096K 1400K 1176K /system/bin/vr_hwc1402 21536K 6648K 1389K 1244K /system/bin/keystore1308 16620K 5884K 1381K 1192K /system/bin/hwservicemanager1403 18776K 4428K 1196K 832K /system/bin/mediadrmserver1378 35308K 5720K 1164K 1020K /vendor/bin/hw/android.hardware.graphics.allocator2.0-service1400 18120K 5608K 1144K 1048K /system/bin/incidentd1412 17428K 6208K 1136K 1004K /system/bin/gatekeeperd1375 17124K 6108K 1115K 952K /vendor/bin/hw/android.hardware.drm1.1-service.clearkey3778 13040K 3488K 1077K 1044K procrank1374 18524K 4060K 1066K 780K /vendor/bin/hw/android.hardware.drm1.0-service1369 16828K 4728K 1061K 844K /vendor/bin/hw/android.hardware.bluetooth1.0-service-qti1011 7192K 2032K 1056K 732K /sbin/ueventd1490 9552K 3384K 1048K 1016K /system/bin/ip6tables-restore1376 15100K 5616K 981K 876K /vendor/bin/hw/android.hardware.gatekeeper1.0-service1384 33900K 4972K 944K 844K /vendor/bin/hw/android.hardware.sensors1.0-service1489 9536K 3124K 929K 900K /system/bin/iptables-restore1413 17792K 4492K 919K 848K /system/bin/perfprofd1392 14920K 5272K 908K 824K /system/bin/thermalserviced1372 11840K 3728K 903K 628K /vendor/bin/hw/android.hardware.cas1.0-service1310 13932K 4760K 861K 780K /vendor/bin/hw/android.hardware.keymaster3.0-service1373 15192K 4516K 844K 764K /vendor/bin/hw/android.hardware.configstore1.1-service1009 7064K 1804K 842K 528K /init1380 11988K 4388K 834K 696K /vendor/bin/hw/android.hardware.health2.0-service.default1307 11096K 3760K 826K 764K /system/bin/servicemanager1388 31500K 4084K 825K 768K /system/bin/ldinit2830 9228K 3188K 799K 764K /data/local/tmp/.studio/process-tracker2834 9228K 3256K 798K 764K /data/local/tmp/.studio/process-tracker1423 5760K 816K 776K 776K /system/bin/mdnsd1366 11996K 4244K 759K 700K /system/bin/healthd1309 11096K 3784K 743K 672K /vendor/bin/vndservicemanager1370 12416K 4228K 724K 668K /vendor/bin/hw/android.hardware.broadcastradio1.1-service1010 6936K 1632K 722K 432K /init1396 11336K 3400K 712K 592K /system/bin/traced_probes1385 12876K 4088K 700K 644K /vendor/bin/hw/android.hardware.usb1.0-service1383 11844K 4160K 694K 632K /vendor/bin/hw/android.hardware.power1.1-service.default1381 11764K 4196K 692K 636K /vendor/bin/hw/android.hardware.light2.0-service1365 11724K 4304K 687K 616K /system/bin/hw/android.hidl.allocator1.0-service1386 11752K 4024K 680K 624K /vendor/bin/hw/android.hardware.vibrator1.0-service.default1382 11728K 4200K 666K 608K /vendor/bin/hw/android.hardware.oemlock1.0-service.default2824 9388K 3452K 659K 612K logcat1395 11336K 3316K 656K 536K /system/bin/traced3764 9024K 3212K 647K 516K sh3739 9024K 3068K 644K 516K /system/bin/sh1393 9024K 3236K 643K 512K /system/bin/sh1390 9624K 3012K 518K 484K /system/bin/lmkd1414 9388K 2864K 472K 440K /system/bin/tombstoned3746 8028K 772K 288K 132K su3758 5916K 708K 212K 60K /system/xbin/su3745 5916K 696K 208K 64K su3750 5916K 704K 208K 56K /system/xbin/su1426 5916K 612K 177K 68K /system/xbin/su------ ------ ------582656K 418368K TOTALRAM: 1015336K total, 257140K free, 3196K buffers, 323996K cached, 828K shmem, 54780K slab数据有点多我们做个筛选 :/ # procrank | grep koom2888 3247024K 115544K 39743K 32996K com.kwai.koom.demo这里 vss3247024K rss115544K 而上面 VmSize: 4014224 kB VmRSS: 114004 kB 数据总体差不多但是细节有点差异推测是同一概念因为虚拟内存作为一种内存管理技术会在进程运行不同阶段发生动态变化。 /proc/meminfo 我这边运行是在虚拟机上面跑到Android系统给机器分配了1G的内存。 运行命令 127|:/ # cat /proc/meminfo MemTotal: 1015336 kB MemFree: 277452 kB MemAvailable: 573328 kB Buffers: 3392 kB Cached: 322680 kB SwapCached: 0 kB Active: 511760 kB Inactive: 130752 kB Active(anon): 319152 kB Inactive(anon): 384 kB Active(file): 192608 kB Inactive(file): 130368 kB Unevictable: 2824 kB Mlocked: 2824 kB SwapTotal: 0 kB SwapFree: 0 kB Dirty: 0 kB Writeback: 0 kB AnonPages: 319368 kB Mapped: 242092 kB Shmem: 828 kB Slab: 53360 kB SReclaimable: 17724 kB SUnreclaim: 35636 kB KernelStack: 12144 kB PageTables: 19208 kB NFS_Unstable: 0 kB Bounce: 0 kB WritebackTmp: 0 kB CommitLimit: 507668 kB Committed_AS: 20653316 kB VmallocTotal: 34359738367 kB VmallocUsed: 0 kB VmallocChunk: 0 kB CmaTotal: 0 kB CmaFree: 0 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB DirectMap4k: 34752 kB DirectMap2M: 1013760 kB源码获取的指标有 MemTotalMemFreeMemAvailableCmaTotalION_heap 这里主要是拿到当前机器的物理内存。 这里解释下CmaTotal的概念 在 Linux 内核中CMAContiguous Memory Allocator连续内存分配器是一种内存管理机制旨在为一些对连续内存有特定需求的设备提供分配连续内存的能力。 而ION_heap IONInput-Output Memory Management是Android系统中的一种内存管理框架用于管理设备内存的分配和映射。 ION_heap是ION框架中用于分配内存的堆heap。它允许Android系统和设备驱动程序在需要时动态地分配和管理内存以满足不同应用程序和系统组件的需求。 附 In general, memory footprint has the following rules: VSS RSS PSS USS Overview The aim of this post was to provide information that would assist in interpreting memory reports from various tools so the T Rue memory usage for Linux processes and the system can is determined. Android have a tool called Procrank (/system/xbin/procrank), which lists out the memory usage of Linux processes in order F Rom highest to lowest usage. The sizes reported per process is VSS, RSS, PSS, and USS. For the sake of simplicity in this description, memory would be a expressed in terms of pages, rather than bytes. Linux systems like ours manage memory in 4096 bytes pages at the lowest level. VSS (reported as VSZ from PS) are the total accessible address space of a process. This is the size also includes memory that May is resident in RAM like Mallocs that has been allocated but not written to. VSS is of very little use for determing real memory usage of a process. RSS is the total memory actually held in RAM for a process. RSS can be misleading, because it reports the total all of the the the A-Libraries that process uses, even though a share D library is a loaded into memory once regardless of what many processes use it. RSS isn’t an accurate representation of the memory usage for a single process. pss differs from RSS on that it reports the proportional size of its shared Librari ES, i.e. if three processes all use a shared libraries that have pages, that library would only contribute pages to the PSS is reported for each of the three processes. PSS is a very useful number because if the PSS for all processes in the system is summed together, which is a good repre Sentation for the total memory usage in the system. When a process was killed, the shared libraries that contributed to its PSS would be proportionally distributed to the PSS T Otals for the remaining processes still using that library. In this-a-slightly misleading, because when a process is killed, PSS does not accurately represent the memory Returned to the overall system. USS is the total private memory for a process, i.e. that’s memory that’s completely unique to that process. USS is an extremely useful number because it indicates the true incremental cost of running a particular process. When a process was killed, the USS is actually returned to the system. USS is the best number to watch when initially suspicious of memory leaks in a process. 引用地址Vss/rss/pss/uss of Android Memory (alibabacloud.com) 总结 ----OOM Monitor Memory---- [java] max:201326592 used ratio:2% [proc] VmSize:4010936kB VmRss:108604kB Threads:715 [meminfo] MemTotal:1015336kB MemFree:225820kB MemAvailable:515340kB avaliable ratio:50% CmaTotal:0kB ION_heap:0kB [meet condition] overThresholdCount:1, threadCount: 715 这就是KOOM在Java层内存监控拿到的内存指标。有了这些指标可以比较清晰地知道当前机器和进程内存的情况。
http://www.dnsts.com.cn/news/242537.html

相关文章:

  • 网站建设推广公司哪家权威兰州起点网站建设
  • ps制作网站背景微信公众号微网站怎么做的
  • 深圳建设注册中心网站长沙感染人数最新消息
  • 湖北省建设厅官方网站电话深圳外贸网站制作价格
  • 成都广告公司网站建设字体设计海报
  • 徐州cms建站系统山东网站建设流程
  • 下载建设银行官方网站下载安装做pc端网站公司
  • 医保局微网站开发网站没有收录从哪开始做优化
  • 网站没有域名设置网站面包屑导航代码
  • 推广链接点击器app智能网站优化 cms 加盟
  • 南京网站公司哪家好dw建网站具体步骤
  • 国泰君安官方网站建设集团广州品牌网站制作公司
  • 网站树状栏目有点唐山网站开发
  • 站长工具在线东营网站排名优化公司
  • 在线手机网站建设沙坪坝集团网站建设
  • 公司网站应该包括哪些内容微信开放平台表情包
  • 网站如何才能被百度收录写代码做网站需要多好的cpu
  • 网站建设公司好吗搜索微信公众号平台
  • 毛绒玩具东莞网站建设英文网站建设教程
  • 古镇免费网站建设网上推广产品哪个网好
  • 哈尔滨有多少家网站建设公司网站开发属于软件开发吗
  • 微餐饮网站建设平台网页设计专业前景如何
  • 怎么把自己做的网站发到网上通过网址来查看袜子技术支持北京网站建设
  • 制作网站的知识营销策划方案目录
  • 个人网站设计策划库尔勒市建设路街道办网站
  • 建设部网站法律法规房产网新房
  • 做网站用php如何学习十大网站开发公司
  • 竭诚网络网站建设公司网站建设的三要素
  • 苏州网站关键词推广接广告的平台推荐
  • 企业网站建设不要空间可以吗东莞建设银行