Talha
Talha

Reputation: 12717

what are the factors that causes these differences between heap sizes and allocated memory?

I have tracked the heap size and allocated memory on different devices. I wonder why are there differences between these values and what is your approach to it? Thanks for your helps.

my layout.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <FrameLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerInParent="true" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:src="@drawable/square1" />

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:text="@string/hello_world"
            android:textSize="@dimen/txt_size" />

    </FrameLayout>

</RelativeLayout>

Devices

Devices

i9100

i9100

p6700

p6700

n7000

n7000

Upvotes: 1

Views: 180

Answers (1)

Robert Estivill
Robert Estivill

Reputation: 12477

The dalvik vm heap size is set on the /system/build.prop preferences file on each android version/device. The exact preference key is dalvik.vm.heapsize. The value is in megabytes and it depends on the device capabilities

How to deal with the different values? Here are some general hints

  • Always make your app usable on the lowest specs device you plan to support
  • Provide all type of resources for each type of device, specially images and videos.
  • Be extra carefull with references as they might prevent the garbage collector from getting memory back (aka. memory leaks)

Upvotes: 2

Related Questions