1. 程式人生 > >android Failed to allocate a 16 byte allocation with 232 free bytes and 232B until OOM; failed due to fragmentation (required co

android Failed to allocate a 16 byte allocation with 232 free bytes and 232B until OOM; failed due to fragmentation (required co

測試上傳超大影片檔案,結果Android APP crash 掉,錯誤訊息是:

Failed to allocate a 16 byte allocation with 232 free bytes and 232B until OOM; failed due to fragmentation (required continguous free 4096 bytes for a new buffer where largest contiguous free 0 bytes)

截圖:

依照這篇加入
android:largeHeap=”true” 屬性在 manifest.xml

ex:

  <application
 android:name=".ParaseApplication"
 android:allowBackup="true"
 android:icon="@mipmap/ic_launcher"
 android:label="@string/app_name"
 android:theme="@style/AppTheme"
 android:largeHeap="true" >

Wow, 真的可以跑了,但換 web server 掛掉:
Malformed HTTP message: Content-Length too long

解法是,超過一定大小的檔案改用 upload_session_start / append / finish API.