【问题标题】:what are the factors that causes these differences between heap sizes and allocated memory?导致堆大小和分配的内存之间存在这些差异的因素是什么?
【发布时间】:2012-11-06 19:50:14
【问题描述】:

我已经跟踪了堆大小并在不同设备上分配了内存。我想知道为什么这些价值观之间存在差异,您的处理方法是什么?感谢您的帮助。

我的 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>

设备

i9100

p6700

n7000

【问题讨论】:

    标签: android memory-management heap-memory


    【解决方案1】:

    dalvik vm 堆大小在每个 android 版本/设备上的 /system/build.prop 首选项文件中设置。确切的偏好键是 dalvik.vm.heapsize。该值以兆字节为单位,取决于设备功能

    如何处理不同的值?以下是一些一般性提示

    • 始终让您的应用在您计划支持的最低规格设备上可用
    • 为每种类型的设备提供所有类型的资源,特别是图像和视频。
    • 对引用要格外小心,因为它们可能会阻止垃圾收集器取回内存(也就是内存泄漏)

    【讨论】:

      猜你喜欢
      • 2021-05-27
      • 2018-08-24
      • 2015-08-29
      • 2015-11-25
      • 2012-05-02
      • 2021-03-24
      • 2019-11-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多