乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      Android——內(nèi)存調(diào)試

       James130 2015-10-24

      因調(diào)試某個(gè)重大問(wèn)題,懷疑到了內(nèi)存,專門寫了個(gè)測(cè)試腳本,記錄一下。

      一.調(diào)試準(zhǔn)備

      首先需要開(kāi)啟android系統(tǒng)的adb功能,start adbd

      PC端 adb connect IP ADDRESS

      如果 出現(xiàn)adb 異??梢試L試 adb kill-server ; adb start-server

      二.adb shell指令

      1.查看整體內(nèi)存

      連上adb之后 可以通過(guò) adb shell procrank 來(lái)查看當(dāng)前的內(nèi)存情況!


      • VSS - Virtual Set Size 虛擬耗用內(nèi)存(包含共享庫(kù)占用的內(nèi)存)
      • RSS - Resident Set Size 實(shí)際使用物理內(nèi)存(包含共享庫(kù)占用的內(nèi)存)
      • PSS - Proportional Set Size 實(shí)際使用的物理內(nèi)存(比例分配共享庫(kù)占用的內(nèi)存)
      • USS - Unique Set Size 進(jìn)程獨(dú)自占用的物理內(nèi)存(不包含共享庫(kù)占用的內(nèi)存)

      2.查看指定進(jìn)程的內(nèi)存情況

      adb shell dumpsys meminfo (包名或者PID)

      3.占用內(nèi)存最多的進(jìn)程或線程

      adb shell top

      顯示當(dāng)前占用最高內(nèi)存的10個(gè)進(jìn)程,adb shell top -m 10


      查看線程:adb shell top -t -m 10

      三.shell 腳本

      用于實(shí)時(shí)監(jiān)控內(nèi)存使用情況,并且保存log,我的shell script:

      1. #!/bin/bash     
      2. echo "Begain test memory">memeory_recode.txt    
      3. i=0    
      4. while true; do    
      5.     
      6. adb shell procrank |grep 'RAM:'| tee -a memeory_record.txt    
      7.      
      8. memoryinfo=$(tail memeory_record.txt -n 1)     
      9. #freememory=$memoryinfo | cut -d ' '-f 4    
      10.     
      11. freememory=`echo "$memoryinfo"|awk -F ' ' '{print $4}'`    
      12.     
      13. free=${freememory%?}    
      14.     
      15. if [ $free -lt 8000 ];then    
      16. echo -e "\033[31mFree Memory is $free KB Less than 8M\033[0m"| tee -a memeory_recode.txt    
      17. adb shell top -m 10 -n 1 | tee -a memeory_recode.txt    
      18. else    
      19. echo "freememory == $free KB"    
      20. fi    
      21.     
      22. i=$(($i+1))    
      23.     
      24.  sleep 1    
      25.     
      26. var=$(date)    
      27. echo "jscese display memory at $var the  $i times"    
      28. echo     
      29. done   

      保存RAM信息的情況到 memeory_record.txt,并且解析freememory 的值,如果少于8000K就把占用內(nèi)存最高的10個(gè)進(jìn)程信息也保存進(jìn)record。

      四.build.prop中的Dalvik設(shè)置

      1. dalvik.vm.heapstartsize=8m  
      2. dalvik.vm.heapgrowthlimit=96m  
      3. dalvik.vm.heapsize=256m  
      4. dalvik.vm.heaptargetutilization=0.75  
      5. dalvik.vm.heapminfree=512k  
      6. dalvik.vm.heapmaxfree=8m  
      7. dalvik.vm.lockprof.threshold=500  
      8. dalvik.vm.dexopt-flags=m=y  

      這幾個(gè)屬性代表了對(duì)dalvik的一些屬性設(shè)置,可以在/dalvik/vm/alloc/HeapSource.cpp下找到原型:
      1. struct HeapSource {  
      2.     /* Target ideal heap utilization ratio; range 1..HEAP_UTILIZATION_MAX 
      3.      */  
      4.     size_t targetUtilization;  
      5.   
      6.     /* The starting heap size. 
      7.      */  
      8.     size_t startSize;  
      9.   
      10.     /* The largest that the heap source as a whole is allowed to grow. 
      11.      */  
      12.     size_t maximumSize;  
      13.   
      14.     /* 
      15.      * The largest size we permit the heap to grow.  This value allows 
      16.      * the user to limit the heap growth below the maximum size.  This 
      17.      * is a work around until we can dynamically set the maximum size. 
      18.      * This value can range between the starting size and the maximum 
      19.      * size but should never be set below the current footprint of the 
      20.      * heap. 
      21.      */  
      22.     size_t growthLimit;  
      23.   
      24.     /* The desired max size of the heap source as a whole. 
      25.      */  
      26.     size_t idealSize;  
      27.   
      28.     /* The maximum number of bytes allowed to be allocated from the 
      29.      * active heap before a GC is forced.  This is used to "shrink" the 
      30.      * heap in lieu of actual compaction. 
      31.      */  
      32.     size_t softLimit;  
      33.   
      34.     /* Minimum number of free bytes. Used with the target utilization when 
      35.      * setting the softLimit. Never allows less bytes than this to be free 
      36.      * when the heap size is below the maximum size or growth limit. 
      37.      */  
      38.     size_t minFree;  
      39.   
      40.     /* Maximum number of free bytes. Used with the target utilization when 
      41.      * setting the softLimit. Never allows more bytes than this to be free 
      42.      * when the heap size is below the maximum size or growth limit. 
      43.      */  
      44.     size_t maxFree;  
      45.   
      46. ...  
      47.   
      48. }  

      大體對(duì)應(yīng)的意思如下:

      1.heapstartsize——堆初始分配的大小,一個(gè)app啟動(dòng)的時(shí)候分配的內(nèi)存大小

      2.heapgrowthlimit——分配的一個(gè)堆最大的增長(zhǎng)值,一個(gè)app最多分配的內(nèi)存大小,超出的話應(yīng)該會(huì)報(bào)outofmemory

      3.heapsize——整個(gè)堆所能達(dá)到的最大值,也就是應(yīng)用程序所能用的內(nèi)存總和

      4.heaptargetutilization——代表堆的利用率,實(shí)際使用與最大利用對(duì)比

      5.heapminfree——堆大小的限制因素,在堆的大小沒(méi)超過(guò)限定值的情況下 最小的空閑值

      6.heapmaxfree——和最小相反,堆中最多能空閑的大小

      7.lockprof.threshold——調(diào)試記錄程序內(nèi)部鎖資源爭(zhēng)奪的閾值,默認(rèn)值是500

      8.dexopt-flags——程序代碼的校驗(yàn)與優(yōu)化,以下來(lái)自百科:

      dalvik.vm.dexopt-flags:
      本參數(shù)控制Dalvik虛擬機(jī)的程序代碼校驗(yàn)和優(yōu)化??商顚懙闹涤衜、v和o?!為標(biāo)準(zhǔn)選項(xiàng),可以是m=y或 m=n。若m=y則啟用不安全代碼的校驗(yàn)和托管代碼的優(yōu)化。兼容性和安全性最高,推薦使用?!為校驗(yàn)選項(xiàng),可與o并存??梢允莢=a或v=n。若v=a 則表示校驗(yàn)所有代碼,v=n則關(guān)閉代碼的校驗(yàn)?!為優(yōu)化選項(xiàng),可與v并存??梢允莖=v或o=a。若o=v則表示優(yōu)化以校驗(yàn)過(guò)的代碼,o=a則表示優(yōu)化 所有代碼?!±纾骸alvik.vm.dexopt-flags=m=y dalvik.vm.dexopt-flags=v=n,o=v
      注意,這個(gè)參數(shù)只會(huì)影響到安裝APK之后或初次使用APK時(shí)生成dex文件時(shí)有效。若整個(gè)系統(tǒng)(包括應(yīng)用程序)為odex化,則無(wú)意義。

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多