样本" Hello-world" Android中的应用需要18MB的内存

时间:2014-11-06 06:49:08

标签: java android eclipse ram android-memory

我使用eclipse创建了一个新的Android项目,这是一个“Hello World!”应用

我在Nexus 4 with Kitkat 4.4.4上运行了此应用,并使用以下命令检查了内存使用情况:

adb shell dumpsys meminfo com.example.test

给了我以下结果

Memory Dump

根据我对此的理解,该应用程序占用了大约 18MB 的RAM。

令我困扰的是,像这样的简单应用程序如何占用大量内存。

这是Android应用程序中的正常行为吗?或者我做错了什么。

请帮我解决这个问题。

参考MainActivity

的源代码
package com.example.test;

import android.app.Activity;
import android.os.Bundle;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

    }
}

reference文件夹中的'activity_main.xml'

<LinearLayout 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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.test.MainActivity" 
android:orientation="vertical">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/hello_world" />

我在Android版4.3 Jellybean上运行了相同的应用程序并命令

adb shell dumpsys meminfo com.example.test

给了我这个结果:

memory used in 4.3 Jellibean

这是因为不同版本的差异吗?与JellyBean相比,为什么Google在Kitkat中改变了这种行为

0 个答案:

没有答案