2012-05-25 612 views
0

我在我的android清單中添加了android:largeHeap =「true」屬性,但它在我的應用程序允許的內存中似乎沒有差別。當我在我的宏碁A100運行下面的活動(運行Android 3.2.1),我得到如下結果:android:largeHeap屬性不起作用?

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> 

回答

1

糟糕,largeHeap屬性所屬的「應用程序」標籤。