{"id":370,"date":"2012-02-17T13:44:34","date_gmt":"2012-02-17T05:44:34","guid":{"rendered":"http:\/\/guoh.ai\/lifelog\/?p=370"},"modified":"2012-02-17T13:47:03","modified_gmt":"2012-02-17T05:47:03","slug":"use-smem-for-view-memory-satisics","status":"publish","type":"post","link":"https:\/\/guoh.ai\/lifelog\/2012\/02\/use-smem-for-view-memory-satisics\/","title":{"rendered":"\u7528smem\u6765\u67e5\u770bAndroid\u5185\u5b58\u4f7f\u7528\u60c5\u51b5"},"content":{"rendered":"<p>\u73b0\u5728\u6211\u4eec\u7528agcc\u6765\u7f16\u8bd1\u4e00\u4e2a\u771f\u6b63\u6709\u7528\u7684\u4e1c\u897f(smem)\uff0c\u7136\u540e\u8ba9\u5b83\u8dd1\u5728Android\u4e0a\u9762\uff0c\u8fd9\u662f\u4e00\u4e2a\u7528\u6765\u67e5\u770bMemory Usage\u7684\u5de5\u5177\uff0c\u5b83\u6bd4Android\u539f\u751f\u7684procmem\u51c6\u786e\u3002<br \/>\n\u5bf9\u505aMemory Optimization\u662f\u5f88\u6709\u7528\u5904\u7684\u4e00\u4e2a\u547d\u4ee4\u5de5\u5177\u3002<br \/>\n\u5982\u4f55\u642d\u5efa\u7f16\u8bd1smem\u7684\u7f16\u8bd1\u73af\u5883\u8bf7\u53c2\u8003<a href=\"http:\/\/guoh.ai\/lifelog\/2012\/02\/run-native-c-code-on-android\/\" target=\"_blank\">\u5728Android\u4e0a\u904b\u884c\u672c\u5730C\u8a9e\u8a00\u4ee3\u78bc<\/a>\uff0c\u6587\u4e2d\u6709\u8bf4\u660e\u600e\u4e48\u642d\u5efa\u548c\u4f7f\u7528aggc\u6765\u7f16\u8bd1\u5728Android\u4e0a\u8fd0\u884c\u7684\u672c\u5730\u7a0b\u5e8f<br \/>\n\u8be6\u7ec6\u4fe1\u606f\u67e5\u770bhttp:\/\/www.elinux.org\/Using_smem_on_Android<\/p>\n<p>\u73b0\u5728\u5f00\u59cb\u8ba9\u5b83\u8dd1\u5728Android\u4e0a\u9762\u5427<\/p>\n<p>\u6700\u5f00\u59cb\u6211\u7528Mercurial\u4e0b\u8f7d\u4e86\u6700\u65b0\u7684\u6e90\u7801(hg clone http:\/\/selenic.com\/repo\/smem)\u7f16\u8bd1\uff0c\u53d1\u73b0\u51fa\u9519\u3002<br \/>\n\u627e\u5230\u4e00\u5c01\u90ae\u4ef6(http:\/\/selenic.com\/pipermail\/smem\/2010-November.txt)\u8bf4\u662f\u53ef\u80fd\u548c\u64cd\u4f5c\u7cfb\u7edf\u7248\u672c\u6709\u5173\u7cfb\uff0c\u6211\u662fUbuntu_X64\u7684\u673a\u5668\u3002<br \/>\n\u6240\u4ee5\u53c8\u91cd\u65b0\u4e0b\u8f7d\u4e86http:\/\/www.selenic.com\/smem\/download\/smem-0.9.tar.gz\uff0c\u8fd9\u4e2a\u7248\u672c\u5bf9\u4e8e\u6211\u6765\u8bf4\u662f\u597d\u7528\u7684\u3002<\/p>\n<p>\u5177\u4f53\u4f7f\u7528\u6b65\u9aa4\u6bd4\u8f83\u7b80\u5355\uff0c\u89e3\u538b\u51fa\u6765\u653e\u5230\u4e00\u4e2a\u6587\u4ef6\u5939\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\/smem-0.9$ agcc smemcap.c -o a-smem\r\n\/smem-0.9$ adb remount\r\n\/smem-0.9$ adb shell mkdir \/data\/smem\r\n\/smem-0.9$ adb push a-smem \/data\/smem\r\n\/smem-0.9$ adb shell<\/pre>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># cd \/data\/smem\r\n# .\/a-smem &gt;&gt; memdata-moto.tar<\/pre>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\/smem-0.9$ adb pull \/data\/smem\/smem_data_moto.tar\r\n\/smem-0.9$ smem -S smem_data_moto.tar<\/pre>\n<p>\u6267\u884c\u8fd9\u4e2a\u547d\u4ee4\u540e\u4f1a\u5f97\u5230\u5982\u4e0b\u8f93\u51fa<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n  PID User     Command                         Swap      USS      PSS      RSS \r\n 1439 1008     \/system\/bin\/akmd2                  0       32       32       36 \r\n12021 0        \/system\/bin\/debuggerd              0       48       49      156 \r\n 1431 0        \/system\/bin\/installd               0       68       70      204 \r\n 1432 1017     \/system\/bin\/keystore \/data\/        0       72       73      168 \r\n 1410 1001     \/system\/bin\/nvm_daemon             0       76       77      204 \r\n 1447 1000     \/system\/bin\/secclkd                0       76       77      192 \r\n 1403 1000     \/system\/bin\/servicemanager         0       80       81      196 \r\n 1430 1002     \/system\/bin\/dbus-daemon --s        0       84       86      212 \r\n18130 0        \/system\/bin\/dhcpcd -ABKL ti        0       92       94      248 \r\n 1409 0        \/system\/bin\/usbd                   0      100      102      240 \r\n 1433 0        \/system\/xbin\/ssmgrd                0      100      102      240 \r\n 1451 0        opprofdaemon                       0      100      107      276 \r\n 1421 1001     \/system\/bin\/rild_tcmd              0      100      121      344 \r\n 1413 0        \/system\/bin\/gkisystem              0      112      125      332 \r\n 1423 0        \/system\/bin\/catcommands            0      108      125      352 \r\n 1437 1001     \/system\/bin\/panic_daemon           0      124      126      316 \r\n 1405 0        \/system\/bin\/netd                   0      144      152      300 \r\n 1404 0        \/system\/bin\/vold                   0      152      160      316 \r\n 1422 0        \/system\/bin\/battd                  0      164      167      372 \r\n19390 0        \/system\/bin\/sh -                   0      144      173      376 \r\n 1449 0        location                           0      168      191      428 \r\n 1402 0        \/sbin\/adbd                         0      228      228      248 \r\n    1 0        \/init                              0      260      260      288 \r\n 1444 1001     \/system\/bin\/brcm_guci_drv -        0      276      287      496 \r\n 1758 0        \/system\/bin\/wpa_supplicant         0      324      326      476 \r\n 1435 0        \/system\/bin\/tcmd                   0      344      347      536 \r\n19392 0        .\/a-smem                           0      336      361      540 \r\n 1407 0        \/system\/bin\/rild                   0      472      506      828 \r\n 1448 0        protocol_driver                    0      740      776     1096 \r\n 1426 0        zygote \/bin\/app_process -Xz        0     1064     1742    12332 \r\n 1427 1013     \/system\/bin\/mediaserver            0     2028     2034     2324 \r\n19278 10021    android.process.media              0     2388     3335    16900 \r\n 1783 10049    com.motorola.usb                   0     2552     3360    15012 \r\n19257 10074    com.picplz.rangefinder             0     2612     3578    17232 \r\n19266 10093    com.google.android.apps.plu        0     3180     4161    17876 \r\n 2481 10070    com.tencent.mm:push                0     3908     4562    15608 \r\n19311 10053    com.google.android.apps.map        0     2808     5167    21776 \r\n19344 10085    cn.com.fetion                      0     4152     6327    21236 \r\n18709 10053    com.google.android.apps.map        0     5420     6561    20100 \r\n 2011 10030    com.android.mms                    0     5720     6585    18920 \r\n 1834 10059    com.google.process.gapps           0     6004     6704    17952 \r\n19375 10022    com.android.email                  0     5616     6994    21076 \r\n19330 10086    com.tencent.WBlog                  0     4064     7054    22436 \r\n19302 10053    com.google.android.apps.map        0     4940     7510    24692 \r\n 1780 1001     com.android.phone                  0     8960     9690    21508 \r\n 1773 10069    com.cootek.smartinputv5            0     9400    10111    21592 \r\n 7687 10004    android.process.acore              0    12364    14029    26980 \r\n 1693 1000     system_server                      0    39128    40908    57464 \r\n<\/pre>\n<p>\u8fd9\u6837\u4f60\u5c31\u53ef\u4ee5\u770b\u51faAndroid\u4e0a\u6bcf\u4e2aprocess\u6240\u5360\u7528\u7684\u5185\u5b58\u60c5\u51b5\uff0c\u57fa\u672c\u53ef\u4ee5\u6ee1\u8db3\u65e5\u5e38\u4f7f\u7528\u4e86,\u7b80\u5355\u597d\u7528\u3002<br \/>\n\u66f4\u591a\u66f4\u9ad8\u7ea7\u7684\u7528\u6cd5\u53ef\u4ee5\u53c2\u89c1\u4e3b\u9875http:\/\/www.selenic.com\/smem\/\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u73b0\u5728\u6211\u4eec\u7528agcc\u6765\u7f16\u8bd1\u4e00\u4e2a\u771f\u6b63\u6709\u7528\u7684\u4e1c\u897f(smem)\uff0c\u7136\u540e\u8ba9\u5b83\u8dd1\u5728Android\u4e0a\u9762\uff0c\u8fd9\u662f\u4e00\u4e2a\u7528\u6765\u67e5\u770bMemory Usage\u7684\u5de5\u5177\uff0c\u5b83\u6bd4Android\u539f\u751f\u7684procmem\u51c6\u786e\u3002 \u5bf9\u505aMemory Optimization\u662f\u5f88\u6709\u7528\u5904\u7684\u4e00\u4e2a\u547d\u4ee4\u5de5\u5177\u3002 \u5982\u4f55\u642d\u5efa\u7f16\u8bd1smem\u7684\u7f16\u8bd1\u73af\u5883\u8bf7\u53c2\u8003\u5728Android\u4e0a\u904b\u884c\u672c\u5730C\u8a9e\u8a00\u4ee3\u78bc\uff0c\u6587\u4e2d\u6709\u8bf4\u660e\u600e\u4e48\u642d\u5efa\u548c\u4f7f\u7528aggc\u6765\u7f16\u8bd1\u5728Android\u4e0a\u8fd0\u884c\u7684\u672c\u5730\u7a0b\u5e8f \u8be6\u7ec6\u4fe1\u606f\u67e5\u770bhttp:\/\/www.elinux.org\/Using_smem_on_Android \u73b0\u5728\u5f00\u59cb\u8ba9\u5b83\u8dd1\u5728Android\u4e0a\u9762\u5427 \u6700\u5f00\u59cb\u6211\u7528Mercurial\u4e0b\u8f7d\u4e86\u6700\u65b0\u7684\u6e90\u7801(hg clone http:\/\/selenic.com\/repo\/smem)\u7f16\u8bd1\uff0c\u53d1\u73b0\u51fa\u9519\u3002 \u627e\u5230\u4e00\u5c01\u90ae\u4ef6(http:\/\/selenic.com\/pipermail\/smem\/2010-November.txt)\u8bf4\u662f\u53ef\u80fd\u548c\u64cd\u4f5c\u7cfb\u7edf\u7248\u672c\u6709\u5173\u7cfb\uff0c\u6211\u662fUbuntu_X64\u7684\u673a\u5668\u3002 \u6240\u4ee5\u53c8\u91cd\u65b0\u4e0b\u8f7d\u4e86http:\/\/www.selenic.com\/smem\/download\/smem-0.9.tar.gz\uff0c\u8fd9\u4e2a\u7248\u672c\u5bf9\u4e8e\u6211\u6765\u8bf4\u662f\u597d\u7528\u7684\u3002 \u5177\u4f53\u4f7f\u7528\u6b65\u9aa4\u6bd4\u8f83\u7b80\u5355\uff0c\u89e3\u538b\u51fa\u6765\u653e\u5230\u4e00\u4e2a\u6587\u4ef6\u5939\u3002 \/smem-0.9$ agcc smemcap.c -o a-smem \/smem-0.9$ adb remount \/smem-0.9$ adb shell mkdir \/data\/smem \/smem-0.9$ adb push a-smem \/data\/smem \/smem-0.9$ adb shell # cd \/data\/smem # .\/a-smem &gt;&gt; memdata-moto.tar \/smem-0.9$ adb pull \/data\/smem\/smem_data_moto.tar \/smem-0.9$ smem -S smem_data_moto.tar \u6267\u884c\u8fd9\u4e2a\u547d\u4ee4\u540e\u4f1a\u5f97\u5230\u5982\u4e0b\u8f93\u51fa PID User Command Swap USS &hellip; <a href=\"https:\/\/guoh.ai\/lifelog\/2012\/02\/use-smem-for-view-memory-satisics\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">\u7528smem\u6765\u67e5\u770bAndroid\u5185\u5b58\u4f7f\u7528\u60c5\u51b5<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_gfmr_meta_descriptions":[],"_gfmr_multilingual_taxonomy_terms":[],"footnotes":""},"categories":[7],"tags":[21],"class_list":["post-370","post","type-post","status-publish","format-standard","hentry","category-android","tag-memory-optimization"],"_links":{"self":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts\/370","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/comments?post=370"}],"version-history":[{"count":9,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts\/370\/revisions"}],"predecessor-version":[{"id":379,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts\/370\/revisions\/379"}],"wp:attachment":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/media?parent=370"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/categories?post=370"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/tags?post=370"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}