title: java.lang.OutOfMemoryError: Failed to allocate a 6553612 byte allocation with 3696144 free bytes and 3MB until OOM
body: <p>When I load my EmojiActivity, it loads the corresponding layout:</p>
  
  <pre><code>setContentView(R.layout.activity_emoji);
  </code></pre>
  
  <p>That layout has a <code>GridLayout</code> with 25 <code>ImageView</code>'s. </p>
  
  <pre><code>&lt;GridLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_alignParentTop="true"
          android:layout_alignParentStart="true"
          android:columnCount="5"
          android:rowCount="5"&gt;
  
      &lt;ImageView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_row="0"
              android:layout_column="0"
              android:src="@drawable/grinning_emoji_with_smiling_eyes" /&gt;
      &lt;ImageView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_row="0"
              android:layout_column="1"
              android:src="@drawable/hugging_face_emoji" /&gt;
      &lt;ImageView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_row="0"
              android:layout_column="2"
              android:src="@drawable/hungry_face_emoji" /&gt;
      &lt;ImageView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_row="0"
              android:layout_column="3"
              android:src="@drawable/kiss_emoji_with_closed_eyes" /&gt;
      &lt;ImageView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_row="0"
              android:layout_column="4"
              android:src="@drawable/kissing_face_emoji" /&gt;
  
  
      &lt;ImageView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_row="1"
              android:layout_column="0"
              android:src="@drawable/kissing_face_with_smiling_eyes_emoji" /&gt;
      &lt;ImageView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_row="1"
              android:layout_column="1"
              android:src="@drawable/money_face_emoji" /&gt;
      &lt;ImageView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_row="1"
              android:layout_column="2"
              android:src="@drawable/nerd_with_glasses_emoji" /&gt;
      &lt;ImageView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_row="1"
              android:layout_column="3"
              android:src="@drawable/relieved_emoji" /&gt;
      &lt;ImageView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_row="1"
              android:layout_column="4"
              android:src="@drawable/sad_face_emoji" /&gt;
  
  
      &lt;ImageView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_row="2"
              android:layout_column="0"
              android:src="@drawable/slightly_smiling_face_emoji" /&gt;
      &lt;ImageView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_row="2"
              android:layout_column="1"
              android:src="@drawable/smiling_emoji_with_eyes_opened" /&gt;
      &lt;ImageView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_row="2"
              android:layout_column="2"
              android:src="@drawable/smiling_emoji_with_smiling_eyes" /&gt;
      &lt;ImageView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_row="2"
              android:layout_column="3"
              android:src="@drawable/smiling_face_emoji" /&gt;
      &lt;ImageView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_row="2"
              android:layout_column="4"
              android:src="@drawable/smiling_face_emoji_with_blushed_cheeks" /&gt;
  
  
      &lt;ImageView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_row="3"
              android:layout_column="0"
              android:src="@drawable/smiling_face_with_closed_eyes" /&gt;
      &lt;ImageView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_row="3"
              android:layout_column="1"
              android:src="@drawable/smiling_with_sweat_emoji" /&gt;
      &lt;ImageView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_row="3"
              android:layout_column="2"
              android:src="@drawable/smirk_face_emoji" /&gt;
      &lt;ImageView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_row="3"
              android:layout_column="3"
              android:src="@drawable/sunglasses_emoji" /&gt;
      &lt;ImageView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_row="3"
              android:layout_column="4"
              android:src="@drawable/tears_of_joy_emoji" /&gt;
  
  
      &lt;ImageView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_row="4"
              android:layout_column="0"
              android:src="@drawable/tongue_out_emoji" /&gt;
      &lt;ImageView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_row="4"
              android:layout_column="1"
              android:src="@drawable/tongue_out_emoji_with_closed_eyes" /&gt;
      &lt;ImageView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_row="4"
              android:layout_column="2"
              android:src="@drawable/tongue_out_emoji_with_winking_eye" /&gt;
      &lt;ImageView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_row="4"
              android:layout_column="3"
              android:src="@drawable/unamused_face_emoji" /&gt;
      &lt;ImageView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_row="4"
              android:layout_column="4"
              android:src="@drawable/upside_down_face_emoji" /&gt;
  &lt;/GridLayout&gt;
  </code></pre>
  
  <p>The graphics are located in @drawable and their total size is 2.4 megabytes on disk. Each of them is around 100 kilobytes. So I have no idea why a out of memory error would occur with such a light load:</p>
  
  <pre><code>I/art: Starting a blocking GC Alloc
  I/art: Clamp target GC heap from 140MB to 128MB
  I/art: Alloc concurrent mark sweep GC freed 3(96B) AllocSpace objects, 0(0B) LOS objects, 3% free, 124MB/128MB, paused 668us total 18.401ms
  W/art: Throwing OutOfMemoryError "Failed to allocate a 6553612 byte allocation with 4109776 free bytes and 3MB until OOM"
  D/skia: --- allocation failed for scaled bitmap
  D/AndroidRuntime: Shutting down VM
  E/AndroidRuntime: FATAL EXCEPTION: main
                    Process: mobapptut.com.camera2videoimage, PID: 30354
                    java.lang.OutOfMemoryError: Failed to allocate a 6553612 byte allocation with 4109776 free bytes and 3MB until OOM
                        at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
                        at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
                        at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:609)
                        at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
                        at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1080)
                        at android.content.res.Resources.loadDrawableForCookie(Resources.java:2738)
                        at android.content.res.Resources.loadDrawable(Resources.java:2643)
                        at android.content.res.TypedArray.getDrawable(TypedArray.java:870)
                        at android.widget.ImageView.&lt;init&gt;(ImageView.java:152)
                        at android.widget.ImageView.&lt;init&gt;(ImageView.java:140)
                        at android.support.v7.widget.AppCompatImageView.&lt;init&gt;(AppCompatImageView.java:57)
                        at android.support.v7.widget.AppCompatImageView.&lt;init&gt;(AppCompatImageView.java:53)
                        at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:106)
                        at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1013)
                        at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1072)
                        at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
                        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:746)
                        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
                        at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
                        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
                        at android.view.LayoutInflater.rInflate(LayoutInflater.java:838)
                        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
                        at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
                        at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
                        at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
                        at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284)
                        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                        at mobapptut.com.camera2videoimage.EmojiActivity.onCreate(EmojiActivity.java:11)
                        at android.app.Activity.performCreate(Activity.java:6272)
                        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
                        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2387)
                        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2494)
                        at android.app.ActivityThread.access$900(ActivityThread.java:157)
                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1356)
                        at android.os.Handler.dispatchMessage(Handler.java:102)
                        at android.os.Looper.loop(Looper.java:148)
                        at android.app.ActivityThread.main(ActivityThread.java:5551)
                        at java.lang.reflect.Method.invoke(Native Method)
                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
  I/art: Clamp target GC heap from 132MB to 128MB
  I/Process: Sending signal. PID: 30354 SIG: 9
  Disconnected from the target VM, address: 'localhost:8600', transport: 'socket'
  </code></pre>
  
  <p>I am attempting to create snapchat clone and in snapchat they are loading 25 emoji's on the screen. I am using images of small sizes. So what is going on? </p>