Solve the Problem of VM heap and VMheap

Source: Internet
Author: User

Solve the Problem of VM heap and VMheap

<P> get a simple image display program today </p>
LinearLayout linearLayout =(LinearLayout)this.findViewById(R.id.LinearLayout1);        for(int i=0;i<imagePath.length;i++)        {        img[i]=new ImageView(this);        img[i].setImageResource(imagePath[i]);        img[i].setPadding(5, 5, 5, 5);        LayoutParams layoutParams=new LayoutParams(253,148);        img[i].setLayoutParams(layoutParams);        linearLayout.addView(img[i]);        }

The physical machine runs normally, but the following problems occur when running the simulator:

09-07 05:58:48. 972: D/dalvikvm (1981): GC_FOR_ALLOC freed 48 K, 4% free 2739 K/2844 K, paused 24 ms, total 25 ms
09-07 05:58:48. 972: I/dalvikvm-heap (1981): Grow heap (frag case) to 6.412 MB for 3864408-byte allocation
09-07 05:58:48. 992: D/dalvikvm (1981): GC_FOR_ALLOC freed 2 K, 2% free 6510 K/6620 K, paused 18 ms, total 18 ms
09-07 05:58:49. 082: D/dalvikvm (1981): GC_FOR_ALLOC freed 10 K, 2% free 6514 K/6620 K, paused 2 ms, total 2 ms
09-07 05:58:49. 082: I/dalvikvm-heap (1981): Grow heap (frag case) to 10.098 MB for 3864408-byte allocation
09-07 05:58:49. 122: D/dalvikvm (1981): GC_FOR_ALLOC freed <1 K, 2% free 10288 K/10396 K, paused 23 ms, total 23 ms
09-07 05:58:49. 412: D/dalvikvm (1981): GC_FOR_ALLOC freed <1 K, 2% free 10289 K/10396 K, paused 2 ms, total 3 ms
09-07 05:58:49. 412: I/dalvikvm-heap (1981): Grow heap (frag case) to 13.785 MB for 3864408-byte allocation
09-07 05:58:49. 452: D/dalvikvm (1981): GC_FOR_ALLOC freed <1 K, 1% free 14063 K/14172 K, paused 27 ms, total 28 ms
09-07 05:58:49. 722: D/dalvikvm (1981): GC_FOR_ALLOC freed <1 K, 1% free 14064 K/14172 K, paused 3 ms, total 3 ms
09-07 05:58:49. 722: I/dalvikvm-heap (1981): Forcing collection of SoftReferences for 3864408-byte allocation
09-07 05:58:49. 732: D/dalvikvm (1981): GC_BEFORE_OOM freed 9 K, 1% free 14055 K/14172 K, paused 4 ms, total 4 ms
09-07 05:58:49. 732: E/dalvikvm-heap (1981): Out of memory on a 3864408-byte allocation.
09-07 05:58:49. 732: I/dalvikvm (1981): "main" prio = 5 tid = 1 RUNNABLE
09-07 05:58:49. 732: I/dalvikvm (1981): | group = "main" sCount = 0 dsCount = 0 obj = 0xb3d20bd8 self = 0xb8e4d4c0
09-07 05:58:49. 732: I/dalvikvm (1981): | shard id = 1981 nice = 0 sched = 0/0 RGPS = [fopen-error: 2] handle =-1216815008
09-07 05:58:49. 732: I/dalvikvm (1981): | state = R schedstat = (0 0) utm = 18 stm = 1 core = 0
09-07 05:58:49. 732: I/dalvikvm (1981): at android. graphics. BitmapFactory. nativeDecodeAsset (Native Method)
09-07 05:58:49. 732: I/dalvikvm (1981): at android. graphics. BitmapFactory. decodeStream (BitmapFactory. java: 587)
09-07 05:58:49. 732: I/dalvikvm (1981): at android. graphics. BitmapFactory. decodeResourceStream (BitmapFactory. java: 422)
09-07 05:58:49. 732: I/dalvikvm (1981): at android. graphics. drawable. Drawable. createFromResourceStream (Drawable. java: 840)
09-07 05:58:49. 732: I/dalvikvm (1981): at android. content. res. Resources. loadDrawable (Resources. java: 2110)
09-07 05:58:49. 732: I/dalvikvm (1981): at android. content. res. Resources. getDrawable (Resources. java: 700)
09-07 05:58:49. 732: I/dalvikvm (1981): at android. widget. ImageView. resolveUri (ImageView. java: 638)
09-07 05:58:49. 732: I/dalvikvm (1981): at android. widget. ImageView. setImageResource (ImageView. java: 367)
09-07 05:58:49. 732: I/dalvikvm (1981): at com. Y. linearlayout. MainActivity. onCreate (MainActivity. java: 24)
09-07 05:58:49. 732: I/dalvikvm (1981): at android. app. Activity. Wait mcreate (Activity. java: 5231)
09-07 05:58:49. 732: I/dalvikvm (1981): at android. app. Instrumentation. callActivityOnCreate (Instrumentation. java: 1087)
09-07 05:58:49. 732: I/dalvikvm (1981): at android. app. ActivityThread. initialize mlaunchactivity (ActivityThread. java: 2159)
09-07 05:58:49. 732: I/dalvikvm (1981): at android. app. ActivityThread. handleLaunchActivity (ActivityThread. java: 2245)
09-07 05:58:49. 732: I/dalvikvm (1981): at android. app. ActivityThread. access $800 (ActivityThread. java: 135)
09-07 05:58:49. 732: I/dalvikvm (1981): at android. app. ActivityThread $ H. handleMessage (ActivityThread. java: 1196)
09-07 05:58:49. 752: I/dalvikvm (1981): at android. OS. Handler. dispatchMessage (Handler. java: 102)
09-07 05:58:49. 752: I/dalvikvm (1981): at android. OS. low.loop (low.java: 136)
09-07 05:58:49. 752: I/dalvikvm (1981): at android. app. ActivityThread. main (ActivityThread. java: 5017)
09-07 05:58:49. 752: I/dalvikvm (1981): at java. lang. reflect. Method. invokeNative (Native Method)
09-07 05:58:49. 752: I/dalvikvm (1981): at java. lang. reflect. Method. invoke (Method. java: 515)
09-07 05:58:49. 752: I/dalvikvm (1981): at com. android. internal. OS. ZygoteInit $ MethodAndArgsCaller. run (ZygoteInit. java: 779)
09-07 05:58:49. 752: I/dalvikvm (1981): at com. android. internal. OS. ZygoteInit. main (ZygoteInit. java: 595)
09-07 05:58:49. 752: I/dalvikvm (1981): at dalvik. system. NativeStart. main (Native Method)
09-07 05:58:49. 752: D/skia (1981): --- decoder-> decode returned false
09-07 05:58:49. 752: D/AndroidRuntime (1981): Shutting down VM
09-07 05:58:49. 752: W/dalvikvm (1981): threadid = 1: thread exiting with uncaught exception (group = 0xb3d1fb20)
09-07 05:58:49. 752: E/AndroidRuntime (1981): fatal exception: main
09-07 05:58:49. 752: E/AndroidRuntime (1981): Process: com. Groovy. linearlayout, PID: 1981
09-07 05:58:49. 752: E/AndroidRuntime (1981): java. lang. OutOfMemoryError
09-07 05:58:49. 752: E/AndroidRuntime (1981): at android. graphics. BitmapFactory. nativeDecodeAsset (Native Method)
09-07 05:58:49. 752: E/AndroidRuntime (1981): at android. graphics. BitmapFactory. decodeStream (BitmapFactory. java: 587)
09-07 05:58:49. 752: E/AndroidRuntime (1981): at android. graphics. BitmapFactory. decodeResourceStream (BitmapFactory. java: 422)
09-07 05:58:49. 752: E/AndroidRuntime (1981): at android. graphics. drawable. Drawable. createFromResourceStream (Drawable. java: 840)
09-07 05:58:49. 752: E/AndroidRuntime (1981): at android. content. res. Resources. loadDrawable (Resources. java: 2110)
09-07 05:58:49. 752: E/AndroidRuntime (1981): at android. content. res. Resources. getDrawable (Resources. java: 700)
09-07 05:58:49. 752: E/AndroidRuntime (1981): at android. widget. ImageView. resolveUri (ImageView. java: 638)
09-07 05:58:49. 752: E/AndroidRuntime (1981): at android. widget. ImageView. setImageResource (ImageView. java: 367)
09-07 05:58:49. 752: E/AndroidRuntime (1981): at com. Y. linearlayout. MainActivity. onCreate (MainActivity. java: 24)
09-07 05:58:49. 752: E/AndroidRuntime (1981): at android. app. Activity. Wait mcreate (Activity. java: 5231)
09-07 05:58:49. 752: E/AndroidRuntime (1981): at android. app. Instrumentation. callActivityOnCreate (Instrumentation. java: 1087)
09-07 05:58:49. 752: E/AndroidRuntime (1981): at android. app. ActivityThread. initialize mlaunchactivity (ActivityThread. java: 2159)
09-07 05:58:49. 752: E/AndroidRuntime (1981): at android. app. ActivityThread. handleLaunchActivity (ActivityThread. java: 2245)
09-07 05:58:49. 752: E/AndroidRuntime (1981): at android. app. ActivityThread. access $800 (ActivityThread. java: 135)
09-07 05:58:49. 752: E/AndroidRuntime (1981): at android. app. ActivityThread $ H. handleMessage (ActivityThread. java: 1196)
09-07 05:58:49. 752: E/AndroidRuntime (1981): at android. OS. Handler. dispatchMessage (Handler. java: 102)
09-07 05:58:49. 752: E/AndroidRuntime (1981): at android. OS. Looper. loop (Looper. java: 136)
09-07 05:58:49. 752: E/AndroidRuntime (1981): at android. app. ActivityThread. main (ActivityThread. java: 5017)
09-07 05:58:49. 752: E/AndroidRuntime (1981): at java. lang. reflect. Method. invokeNative (Native Method)
09-07 05:58:49. 752: E/AndroidRuntime (1981): at java. lang. reflect. Method. invoke (Method. java: 515)
09-07 05:58:49. 752: E/AndroidRuntime (1981): at com. android. internal. OS. ZygoteInit $ MethodAndArgsCaller. run (ZygoteInit. java: 779)
09-07 05:58:49. 752: E/AndroidRuntime (1981): at com. android. internal. OS. ZygoteInit. main (ZygoteInit. java: 595)
09-07 05:58:49. 752: E/AndroidRuntime (1981): at dalvik. system. NativeStart. main (Native Method)


Solution: Change the VM Heap value from the default value of 16 to 128.



How many settings are appropriate for the android vm heap tool?

Frds

VM Heap tool, how can I not use this software? I am prompted to write data to system partitions for access instead of being created by your device. Therefore, the change will have to be disabled.

None of the answers is that this sit-in day is two days, and if you live for 70 years, it is one hundred and forty-Su Shi

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.