{"id":872,"date":"2018-04-18T20:00:20","date_gmt":"2018-04-18T11:00:20","guid":{"rendered":"http:\/\/bellsprite.com\/?p=872"},"modified":"2018-06-25T20:54:35","modified_gmt":"2018-06-25T11:54:35","slug":"%e8%bf%91%e6%9c%9f%e5%b7%a5%e4%bd%9c%e5%86%85%e5%ae%b9%e8%ae%b0%e5%bd%95","status":"publish","type":"post","link":"https:\/\/bellsprite.com\/?p=872","title":{"rendered":"\u8fd1\u671f\u5de5\u4f5c\u5185\u5bb9\u8bb0\u5f55"},"content":{"rendered":"<p style=\"text-align: center;\"><a href=\"https:\/\/bellsprite.com\/blog\/wp-content\/uploads\/2018\/04\/unnamed.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-875 aligncenter\" alt=\"unnamed\" src=\"http:\/\/bellsprite.com\/blog\/wp-content\/uploads\/2018\/04\/unnamed.png\" width=\"300\" height=\"477\" srcset=\"https:\/\/bellsprite.com\/wp-content\/uploads\/2018\/04\/unnamed.png 300w, https:\/\/bellsprite.com\/wp-content\/uploads\/2018\/04\/unnamed-188x300.png 188w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p style=\"text-align: left;\">\u5de5\u4f5c\u4e0a\u9047\u5230 android app \u610f\u5916\u53d1\u751f Bitmap \u5185\u5b58\u6cc4\u6f0f\u7684\u95ee\u9898\u3002\u628a vm heap dump \u4e0b\u6765\u4e00\u770b\u4e0d\u5f97\u4e86\uff0c\u6709\u5927\u91cf byte[] \u6570\u7ec4\u9a7b\u7559\u5728 vm \u5185\u5b58\u5185\uff0c\u4f46\u5374\u6ca1\u6709\u88ab\u4efb\u4f55\u5bf9\u8c61\u5f15\u7528\u5230\uff01\u660e\u660e\u6211\u4eec\u7684 app \u5185\u5b58\u4e0d\u8db3\u5230\u90fd\u5d29\u6e83\u4e86\uff0cgc \u8fd8\u4e0d\u56de\u6536\u8fd9\u4e9b\u5783\u573e byte[]\uff0c\u8fd9\u662f\u4e3a\u4ec0\u4e48\uff1f\u800c\u4e14\u8fd9\u4e2a\u73b0\u8c61\u5728 android 6.0 \u4e0a\u53d1\u751f\uff0c\u4f46\u5728 android 7.1 \u548c 8.0 \u4e0a\u90fd\u4e0d\u4f1a\u53d1\u751f\u3002\u800c\u4e14\uff0c\u5728\u6211\u4eec\u7684 app \u9000\u51fa\u90a3\u4e2a\u4f1a\u5bfc\u81f4\u8fd9\u4e2a\u5185\u5b58\u6cc4\u6f0f\u7684 view \u4e4b\u540e\uff0cgc\u53c8\u53ef\u4ee5\u6b63\u786e\u56de\u6536\u90a3\u4e9b\u5e7d\u7075\u6570\u7ec4\u4e86\u3002\u603b\u89c9\u5f97\uff0c\u597d\u795e\u79d8\uff01<br \/>\u7a0d\u5fae\u8bfb\u4e86\u4e00\u4e0b\u5404\u4e2a\u7248\u672c android \u7684 Bitmap \u7684 java \u548c jni \u4ee3\u7801\u4e4b\u540e\uff0c\u6211\u89c9\u5f97\u8fd9\u662f\u56e0\u4e3a\u5185\u5b58\u867d\u7136\u88ab\u6807\u8bb0\u4e3a\u865a\u62df\u673a\u5185\u5185\u5b58\uff0c\u4f46\u662f\u521b\u5efa\u548c\u91ca\u653e\u90fd\u662f\u7531 native \u5c42\u7ba1\u7406\u7740\uff0c\u800c native \u5c42\u51fa\u4e8e\u67d0\u4e9b\u539f\u56e0\uff0c\u4e0d\u613f\u610f\u53ca\u65f6\u91ca\u653e\u8fd9\u6279\u5185\u5b58\u6240\u5bfc\u81f4\u7684\u3002\u662f\u4e00\u8d77\u6709\u7ec4\u7ec7\u6709\u9884\u8c0b\u7684\u79c1\u85cf\u5185\u5b58\u4e8b\u4ef6\u3002<br \/>\u600e\u4e48\u529e\u5462\uff0cnative debugger attach \u4e0a\uff0c\u76f4\u63a5\u8c03\u8bd5 native \u5c42\u5427\uff0c\u6ca1\u6709 symbols\uff0c\u770b\u4e0d\u5230\u6e90\u7801\u548c\u53d8\u91cf\uff0c\u53ea\u80fd\u770b\u5230\u8fdb\u5165\u4e86\u54ea\u4e2a\u51fd\u6570\u548c\u4efb\u610f\u65f6\u523b\u5bc4\u5b58\u5668\u7684\u6570\u503c\uff0c\u8fd9\u8c03\u8bd5\u8d77\u6765\u771f\u662f\u4e24\u773c\u4e00\u62b9\u9ed1\uff0c\u4e8b\u500d\u529f\u534a\u3002<br \/>\u60f3\u8981\u6709\u6e90\u7801\u8c03\u8bd5\uff1f\u53ef\u4ee5\u554a\uff0c\u81ea\u5df1\u7f16\u8bd1 aosp (android open source project)\uff0c\u7528\u81ea\u5df1\u7f16\u8bd1\u7684 system.img \u542f\u52a8\u6a21\u62df\u5668\u5c31\u53ef\u4ee5\u6709\u6e90\u7801\u8c03\u8bd5\u4e86\u3002\u4e8e\u662f\u82b1\u4e86\u4e00\u4e2a\u661f\u671f\u5404\u79cd\u5f0f\u9519\u540e\u7ec8\u4e8e\u7528\u4e0a\u4e86\u81ea\u5df1\u7684 system.img,\u81ea\u8c6a\uff01\u7ed3\u679c\u53d1\u73b0\u7528\u6211\u7684 system.img \u4e4b\u540e\u5185\u5b58\u5c31\u4e0d\u6cc4\u6f0f\u4e86\u3002\u800d\u6211\u54e6\uff01<br \/>\u7ec6\u81f4\u8c03\u67e5\u540e\u53d1\u73b0\u4e0d\u4ec5\u66ff\u6362\u6574\u4e2a system.img \u4f1a\u8fd9\u6837\uff0c\u5c31\u7b97\u53ea\u662f\u66ff\u6362\u6389 android \u4e3b\u673a\uff08\u6a21\u62df\u5668\uff09\u5185\u7684 \/system\/lib\/libandroid_runtime.so \u4e3a\u6211\u7f16\u8bd1\u7684\u7248\u672c\uff0c\u5185\u5b58\u6cc4\u6f0f\u95ee\u9898\u4e5f\u4f1a\u6d88\u5931\u3002\u8fd9\u4e2a .so \u91cc\u5927\u6982\u90fd\u662f android jni \u76f8\u5173\u7684\u4e1c\u897f\uff0c\u5f53\u7136\u6211\u6000\u7591\u7684 Bitmap native \u90e8\u5206\u7684\u5b9e\u73b0\u4e5f\u5728\u91cc\u9762\uff0c\u6240\u4ee5\u6211\u7684\u63a8\u7406\u65b9\u5411\u4f3c\u4e4e\u662f\u6b63\u786e\u7684\u3002\u53ea\u662f\u6ca1\u6cd5\u7ee7\u7eed\u76f4\u7403\u51fa\u51fb\u5206\u80dc\u8d1f\u4e86\uff0c\u9057\u61be\u3002<br \/>\u987a\u4fbf\u8bf4\u4e00\u4e0b\uff0c\u7528 android studio \u7684 android profiler \u7684 memory \u9762\u677f\u67e5\u770b\u5c31\u4f1a\u53d1\u73b0\uff0c\u7528\u4e86\u6211\u7684 .so \u4e4b\u540e app \u7684 native memory \u4f7f\u7528\u91cf\u59cb\u7ec8\u975e\u5e38\u4f4e\uff0c\u800c \u539f\u7248\u6a21\u62df\u5668\u4f1a\u5728 load \u4e00\u4e2a Bitmap \u540e java memory \u548c native memory \u4f1a\u4e00\u8d77\u589e\u51cf\u3002\u76ee\u524d\u6211\u521d\u6b65\u6000\u7591\u662f\u6211\u7f16\u8bd1\u7684\u7248\u672c\u6ca1\u6709\u80fd\u591f\u6b63\u786e\u8bbf\u95ee\u786c\u4ef6\u76f8\u5173\u529f\u80fd\u5bfc\u81f4\u786c\u4ef6\u52a0\u901f\u90e8\u5206\u4ea7\u751f\u4e86\u5dee\u522b\uff0c\u4f46\u8fd8\u6ca1\u6709\u4ec0\u4e48\u8bc1\u636e\u3002<br \/>\u5982\u679c\u662f\u5174\u8da3\u9879\u76ee\uff0c\u6211\u80af\u5b9a\u4f1a\u7ee7\u7eed\u7814\u7a76 aosp \u7684\uff0c\u53ef\u60dc\u8fd9\u6b21\u662f\u5de5\u4f5c\uff0c\u4e0d\u80fd\u592a\u4efb\u6027\u3002\u4e0b\u4e00\u6b65\u6211\u51c6\u672c\u9759\u6001\u5206\u6790 Bitmap \u76f8\u5173\u7684\u4ee3\u7801\uff0c\u914d\u5408\u534a\u778e\u7684 native debugger \u548c\u8bd5\u9519\u6027\u8c03\u6574\u76f8\u5173\u7684 react-native \u90e8\u5206\u4ee3\u7801\u6765\u627e\u51fa\u907f\u514d\u8fd9\u4e00\u5185\u5b58\u6cc4\u6f0f\u7684\u65b9\u6cd5\u3002<br \/>\u4e4b\u524d\u9047\u5230\u8fc7 react-native \u7684\u5706\u89d2\u56fe\u7247\u5bfc\u81f4\u7684 android 7.1 \u4ee5\u4e0b\u7684 app \u4f1a\u53d1\u751f graphics memory \u5185\u5b58\u65e0\u9650\u6cc4\u6f0f\u7684\u95ee\u9898\uff0c\u6700\u540e\u4e5f\u662f\u5728\u6ca1\u7406\u89e3\u6839\u672c\u539f\u56e0\u7684\u60c5\u51b5\u4e0b\u88ab\u6211\u7ed5\u8fc7\u53bb\u4e86\uff0c\u76f8\u4fe1\u8fd9\u6b21\u4e5f\u80fd\u9022\u51f6\u5316\u5409\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5de5\u4f5c\u4e0a\u9047\u5230 android app \u610f\u5916\u53d1\u751f Bitmap \u5185\u5b58\u6cc4\u6f0f\u7684\u95ee\u9898\u3002\u628a vm heap dump \u4e0b\u6765 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_themeisle_gutenberg_block_has_review":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-872","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"views":3386,"_links":{"self":[{"href":"https:\/\/bellsprite.com\/index.php?rest_route=\/wp\/v2\/posts\/872","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bellsprite.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bellsprite.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bellsprite.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bellsprite.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=872"}],"version-history":[{"count":4,"href":"https:\/\/bellsprite.com\/index.php?rest_route=\/wp\/v2\/posts\/872\/revisions"}],"predecessor-version":[{"id":887,"href":"https:\/\/bellsprite.com\/index.php?rest_route=\/wp\/v2\/posts\/872\/revisions\/887"}],"wp:attachment":[{"href":"https:\/\/bellsprite.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=872"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bellsprite.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=872"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bellsprite.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=872"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}