简体   繁体   English

largeHeap = true清单标签不起作用?

[英]largeHeap=true manifest tag not working?

I´m developing a very memory-consuming app and want to use the largeHeap-Tag, which should give the application a bit more memory. 我正在开发一个非常耗费内存的应用程序,并希望使用largeHeap-Tag,它应该为应用程序提供更多内存。 Whatever I set this tag in AndroidManifest.xml to, it makes no difference to the actual memory I´ve been given. 无论我在AndroidManifest.xml中将此标记设置为什么,它对我给出的实际内存没有任何影响。 I´m reading out my max memory like this: 我正在读出这样的最大记忆:

Log.v("Utils","Max Mem in MB:"+(Runtime.getRuntime().maxMemory()/1024/1024));

My manifest looks quite like this: 我的清单看起来很像这样:

<application android:label="@string/app_name" android:hardwareAccelerated="true" android:largeHeap="true" android:debuggable="true">

    <activity android:name=".EntryActivity" android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

</application>

I´m running 3.1 in the emulator, output of my logging above is always 48MB. 我在模拟器中运行3.1,我上面的日志输出总是48MB。 Can somebody help? 有人可以帮忙吗?

使用ActivityManager.getMemoryClass()ActivityManager.getLargeMemoryClass()来验证分配给应用程序的近似值。

Indeed, the large heap will be the same as normal heap until your app needs more memory for a task. 实际上,在您的应用程序需要更多内存用于任务之前,大堆将与普通堆相同。 Your VM will display such messages on console: 您的VM将在控制台上显示此类消息:

06-30 15:38:14.770: INFO/dalvikvm-heap(9075): Grow heap (frag case) to 42.365MB for 6152016-byte allocation
06-30 15:38:16.680: INFO/dalvikvm-heap(9075): Grow heap (frag case) to 39.739MB for 3517456-byte allocation

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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