android 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 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

http://stackoverflow.com/questions/32244851/androidjava-lang-outofmemoryerror-failed-to-allocate-a-23970828-byte-allocatio

 

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.

 

相關文章

寫留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *