我用c语言开发了一个android应用程序,使用xamarin。它占用了大量内存。很长一段时间,我使用了较弱的2GB设备来成功运行它。现在我把手机换成4GB设备,突然我的内存出现异常。这是由创建较大的位图引起的。
(13022): Starting a blocking GC Alloc
(13022): Clamp target GC heap from 271MB to 256MB
(13022): Alloc concurrent mark sweep GC freed 4(96B) AllocSpace objects, 0(0B) LOS objects, 0% free, 255MB/256MB, paused 172us total 13.525ms
(13022): Forcing collection of SoftReferences for 833KB allocation
(13022): Starting a blocking GC Alloc
(13022): Clamp target GC heap from 271MB to 256MB
(13022): Alloc concurrent mark sweep GC freed 5(120B) AllocSpace objects, 0(0B) LOS objects, 0% free, 255MB/256MB, paused 175us total 13.474ms
(13022): Out of memory: Heap Size=256MB, Allocated=255MB, Capacity=256MB
我尝试了所有可能的设置组合
Java Max Heap Size = 1G
android:largeHeap="true"
正如建议的那样
here
编辑:
这是整个清单文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="AlienChessAndroid.AlienChessAndroid" android:versionCode="1" android:versionName="1.0" android:largeHeap="true" android:installLocation="auto">
<uses-sdk android:minSdkVersion="23" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:label="Alien Chess" android:icon="@drawable/Alien">
</application>
</manifest>