Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

largeHeap=true manifest tag not working?

Tags:

java

android

I´m developing a very memory-consuming app and want to use the largeHeap-Tag, which should give the application a bit more memory. Whatever I set this tag in AndroidManifest.xml to, it makes no difference to the actual memory I´ve been given. 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. Can somebody help?

like image 698
stk Avatar asked May 20 '11 17:05

stk


2 Answers

Use ActivityManager.getMemoryClass() and ActivityManager.getLargeMemoryClass() to verify the approximated values assigned to your app.

like image 86
Diego Torres Milano Avatar answered Sep 29 '22 17:09

Diego Torres Milano


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:

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
like image 34
Climbatize Avatar answered Sep 29 '22 17:09

Climbatize