2012-11-18 20 views
1

我已經在不同的設備上跟蹤堆大小和分配的內存。我想知道爲什麼這些價值觀之間存在差異,您對此有何看法?感謝您的幫助。導致堆大小和分配內存之間存在差異的因素是什麼?

我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

回答

2

Dalvik虛擬機的堆的大小被設定在每個偏好Android版本/設備上的文件的/system/build.prop。確切的首選項是dalvik.vm.heapsize。該值以兆字節爲單位,取決於設備功能

如何處理不同的值?下面是一些一般的提示

  • 總能讓你打算支持
  • 提供所有類型的資源,爲每種類型的設備,特別是圖像和視頻的最低規格設備上的應用程序使用。
  • 請特別注意引用,因爲它們可能會阻止垃圾回收器取回內存(又稱內存泄漏)
相關問題