我将 android:largeHeap="true" 属性添加到我的 android 清单中,但它似乎对我的应用程序允许的内存没有影响。当我在我的 Acer A100(运行 android 3.2.1)上运行以下活动时,我得到以下结果:
largeAmount = 256
normalamount = 48
allowedMax = 48
outofmemoryexception allocating the 60mb byte array.
public class TempActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
int largeAmount = manager.getLargeMemoryClass();
int normalAmount = manager.getMemoryClass();
long allowedMax = Runtime.getRuntime().maxMemory()/1024/1024;
byte[] bigarray = new byte[62914560];
}
}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.temp"
android:largeHeap="true"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="11" android:targetSdkVersion="11"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".TempActivity"
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>
</manifest>