【问题标题】:Android Heap size is smaller than 16mbAndroid 堆大小小于 16mb
【发布时间】:2012-06-24 08:43:08
【问题描述】:

我正在开发一个在 Galaxy Tab 10.1 上占用大约 12MB 堆空间的应用程序。

但是,当我在我的 Samsung Vibrant 上测试此应用程序时,它提供了略高于 3MB 的堆,使用的堆大小百分比约为 98%。

有人能解释一下为什么会这样,并帮我找出解决办法吗?

我知道 VMRuntime 已被弃用,但我无法找到增加最小堆大小的替代方法。

谢谢!

【问题讨论】:

    标签: android size heap-memory


    【解决方案1】:

    所有 Android 设备都有不同的应用程序堆大小。

        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
    
            mHeapText = (TextView)findViewById(R.id.mHeapText);
    
            ActivityManager mActivityManager = (ActivityManager)getApplicationContext().getSystemService(ACTIVITY_SERVICE);
            int activityMemory = mActivityManager.getMemoryClass();
            mHeapText.setText("This Device Able to Use for App " + String.valueOf(activityMemory) + "MB");
        }
    

    检查您的 Samsung Vibrant 堆大小。

    【讨论】:

    • 最小为 16MB。 Vibrant 有 48MB。
    猜你喜欢
    • 2016-09-26
    • 1970-01-01
    • 1970-01-01
    • 2019-02-13
    • 2018-09-11
    • 2013-07-04
    • 2018-04-14
    • 2015-04-08
    • 2012-05-27
    相关资源
    最近更新 更多