{"id":187,"date":"2013-01-06T01:31:52","date_gmt":"2013-01-05T16:31:52","guid":{"rendered":"http:\/\/androiphone.uvs.jp\/?p=187"},"modified":"2015-11-09T14:18:56","modified_gmt":"2015-11-09T05:18:56","slug":"android%e7%94%bb%e5%83%8f%e3%82%92%e6%89%b1%e3%81%a3%e3%81%9f%e6%99%82%e3%81%aboutofmemory%e3%81%ab%e6%82%a9%e3%81%be%e3%81%95%e3%82%8c%e3%82%8b","status":"publish","type":"post","link":"https:\/\/androiphone.uvs.jp\/?p=187","title":{"rendered":"[Android]\u753b\u50cf\u3092\u6271\u3063\u305f\u6642\u306bOutOfMemory\u306b\u60a9\u307e\u3055\u308c\u308b"},"content":{"rendered":"<p>\u3057\u3070\u3089\u30fc\u304f\u6295\u7a3f\u3092\u3057\u3066\u3044\u307e\u305b\u3093\u3067\u3057\u305f\u304c\u3001\u300c\u3072\u3089\u304c\u306a\u304b\u3053\u3046\u300d\u3092\u4f5c\u3063\u3066\u307e\u3057\u3066\u3001\u3044\u308d\u3044\u308d\u96e3\u822a\u3057\u307e\u3057\u305f\u3002\u4e00\u756a\u306e\u96e3\u822a\u306f3.0\u7cfb\u30844.0\u7cfb\u3067\u306f\u3001\u6bd4\u8f03\u7684\u3001\u843d\u3061\u306b\u304f\u3044\u3093\u3067\u3059\u304c\u30012.0(2.2\u4ee5\u964d)\u53f0\u3060\u3068\u3001\u3061\u3087\u3063\u3068bitmap\u3092\u6271\u3046\u3068\u3001\u3059\u3050OutOfMemory\u3067\u30af\u30e9\u30c3\u30b7\u30e5\u3057\u307e\u3059\u3002\u307e\u3041\u3001\u3044\u308d\u3044\u308d\u8abf\u3079\u308b\u30682.2\u7cfb\u306b\u5bfe\u5fdc\u3059\u308b\u306e\u3067\u3042\u308c\u3070\u3001\u7279\u306bbitmap\u3084View\u306b\u30bb\u30c3\u30c8\u3057\u305f\u753b\u50cf\u3092\u30af\u30ea\u30fc\u30f3\u30a2\u30c3\u30d7\u3057\u306a\u3044\u3068\u3001\u3059\u3050\u30e1\u30e2\u30ea\u4e0d\u8db3\u3060\u3068\u6012\u3089\u308c\u3066\u3057\u307e\u3044\u307e\u3059\u3002\u4ee5\u4e0b\u306b\u3001\u3042\u308b\u7a0b\u5ea6\u306e\u89e3\u6c7a\u7b56\u3092\u30e1\u30e2\u3068\u3057\u3066\u6b8b\u3057\u307e\u3059\u3002<\/p>\n<p><strong>(1)bitmap\u306f\u4f7f\u308f\u306a\u304f\u306a\u3063\u305f\u3089\u3059\u3050\u30ea\u30b5\u30a4\u30af\u30eb<\/strong><\/p>\n<p><strong>(2)bitmap\u3092\u8aad\u307f\u8fbc\u3080\u3068\u304d\u306fConfig.ARGB_4444(or\u00a0 RGB_565)\u3092\u4f7f\u3046\u3002\u3072\u3089\u304c\u306a\u304b\u3053\u3046\u306f\u30ec\u30a4\u30e4\u30fc\u3067\u66f8\u304d\u9806\u63cf\u753b\u3057\u3066\u3044\u308b\u306e\u3067\u30a2\u30eb\u30d5\u30a1\u304c\u5fc5\u8981\u306a\u305f\u3081ARGB_4444\u3092\u4f7f\u3046\u3002<\/strong><\/p>\n<p><strong>(3)inSampleSize\u3067\u8aad\u307f\u8fbc\u307f\u30b5\u30a4\u30ba\u3092\u30c0\u30a6\u30f3\u30022\u306b\u3059\u308b\u3068\u9762\u7a4d\u6bd41\/4\u306b\u306a\u308b\u3002\u3051\u3069\u7c97\u304f\u306a\u308b\u30fb\u30fb\u30fb<\/strong><\/p>\n<pre>[js highlight=\"2,4,10\"]\r\n\r\nBitmapFactory.Options options = new BitmapFactory.Options();\r\noptions.inPreferredConfig = Config.ARGB_4444;\r\noptions.inPurgeable=true;\r\noptions.inSampleSize=2;\r\nBitmap bitmap_lay2 = BitmapFactory.decodeResource(getResources(),getResources().getIdentifier(bmp_res_array[now_count], &quot;drawable&quot;, &quot;jp.co.sakai.write_hiragana&quot;),options);\r\nbitmap_lay = bitmap_lay2.copy(Bitmap.Config.ARGB_4444, true);\r\nbitmap_lay2.recycle();\r\nbitmap_lay2 = null;\r\n\r\n[\/js]<\/pre>\n<p>\u3042\u3068\u3001ScrollView\u304b\u3089\u306e\u753b\u9762\u9077\u79fb\u6642\u306bOutOfMemory\u304c\u3067\u307e\u304f\u3063\u305f\u3002\u3053\u308c\u306fScrollView\u3092\u30af\u30ea\u30fc\u30f3\u30ca\u30c3\u30d7\u3059\u308b\u3053\u3068\u3067\u3067\u306a\u304f\u306a\u3063\u305f\u3002<\/p>\n<pre>[js]\r\npublic static final void cleanupView(View view) {\r\nif(view instanceof ImageButton) {\r\nImageButton ib = (ImageButton)view;\r\nib.setImageDrawable(null);\r\n} else if(view instanceof ImageView) {\r\nImageView iv = (ImageView)view;\r\niv.setImageDrawable(null);\r\n} else if(view instanceof SeekBar) {\r\nSeekBar sb = (SeekBar)view;\r\nsb.setProgressDrawable(null);\r\nsb.setThumb(null);\r\n}\r\nview.setBackgroundDrawable(null);\r\nif(view instanceof ViewGroup) {\r\nViewGroup vg = (ViewGroup)view;\r\nint size = vg.getChildCount();\r\nfor(int i = 0; i &amp;lt; size; i++) {\r\ncleanupView(vg.getChildAt(i));\r\n} }\r\n\r\n}\r\n[\/js]<\/pre>\n<p>\u753b\u9762\u9077\u79fb\u3059\u308b\u524d\u306b\u3001ScrollView\u306e\u4f4d\u7f6e\u306e\u307f\u3092\u4fdd\u6301\u3057\u3066\u3001Drawable\u306aView\u3092\u4e0a\u306e\u624b\u7d9a\u304d\u3067\u51e6\u7406\u3059\u308c\u3070\u30e1\u30e2\u30ea\u30fc\u4e0d\u8db3\u306b\u9665\u308b\u3053\u3068\u306f\u306a\u304f\u306a\u3063\u305f\u3002\u304c\u3001\u3044\u308d\u3044\u308d\u4f7f\u3063\u3066\u307f\u306a\u3044\u3068\u308f\u304b\u3089\u306a\u3044\u3057\u3001\u624b\u5143\u306b2.2\u7cfb\u306e\u5b9f\u6a5f\u304c\u306a\u3044\u306e\u3067\u30a8\u30df\u30e5\u30ec\u30fc\u30bf\u30fc\u306e\u307f\u306e\u30c1\u30a7\u30c3\u30af\u3068\u306a\u3063\u3066\u3057\u307e\u3044\u3001\u5c11\u3005\u4e0d\u5b89\u3002\u3002\u3002\u3053\u3093\u306a\u3053\u3068\u306a\u3089\u3001\u30b9\u30de\u30db\u306f2.3\u306e\u307e\u307e\u306b\u3057\u3068\u3051\u3070\u3088\u304b\u3063\u305f\u30fb\u30fb\u30fb\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3057\u3070\u3089\u30fc\u304f\u6295\u7a3f\u3092\u3057\u3066\u3044\u307e\u305b\u3093\u3067\u3057\u305f\u304c\u3001\u300c\u3072\u3089\u304c\u306a\u304b\u3053\u3046\u300d\u3092\u4f5c\u3063\u3066\u307e\u3057\u3066\u3001\u3044\u308d\u3044\u308d\u96e3\u822a\u3057\u307e\u3057\u305f\u3002\u4e00\u756a\u306e\u96e3\u822a\u306f3.0\u7cfb\u30844.0\u7cfb\u3067\u306f\u3001\u6bd4\u8f03\u7684\u3001\u843d\u3061\u306b\u304f\u3044\u3093\u3067\u3059\u304c\u30012.0(2.2\u4ee5\u964d)\u53f0\u3060\u3068\u3001\u3061\u3087\u3063\u3068bitmap\u3092\u6271\u3046\u3068\u3001\u3059\u3050 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"","_original_post":"","footnotes":""},"categories":[5,6],"tags":[],"class_list":["post-187","post","type-post","status-publish","format-standard","hentry","category-android","category-6","ja"],"_links":{"self":[{"href":"https:\/\/androiphone.uvs.jp\/index.php?rest_route=\/wp\/v2\/posts\/187","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/androiphone.uvs.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/androiphone.uvs.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/androiphone.uvs.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/androiphone.uvs.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=187"}],"version-history":[{"count":8,"href":"https:\/\/androiphone.uvs.jp\/index.php?rest_route=\/wp\/v2\/posts\/187\/revisions"}],"predecessor-version":[{"id":945,"href":"https:\/\/androiphone.uvs.jp\/index.php?rest_route=\/wp\/v2\/posts\/187\/revisions\/945"}],"wp:attachment":[{"href":"https:\/\/androiphone.uvs.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=187"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/androiphone.uvs.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=187"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/androiphone.uvs.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=187"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}