简体   繁体   中英

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

设备

i9100

i9100

p6700

p6700

n7000

n7000

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM