Skip to content Skip to sidebar Skip to footer

Out Of Memory Error For Files Greater Than 3mb Though Upload Using Chunk

double bytes = file.length(); double kilobytes = (bytes / 1024); double megaBytes = (kilobytes/1024);

Solution 1:

The problem is you are not sending the data as you read it. You are creating a large buffer which doesn't help you at all because a file can be read in one go if you needed this, but you don't.

Just send the data as you read it and you won't use more memory for larger files. I.e. instead of writing to bos write straight to the socket output stream.

BTW You can use Base64, but this is larger and would use more memory (unless you sent the data as you read it as I suggested)

Solution 2:

Go to AndroidManifest.xml file and put this :

android:largeHeap="true"

For example:

<applicationandroid:allowBackup="true"android:label="@string/name"android:largeHeap="true"android:theme="@style/AppTheme" ><activityandroid:name="pt.example.test"android:label="@string/app_name"><intent-filterandroid:label="@string/name" ><actionandroid:name="android.intent.action.MAIN" /><categoryandroid:name="android.intent.category.LAUNCHER" /></intent-filter></activity></application>

Post a Comment for "Out Of Memory Error For Files Greater Than 3mb Though Upload Using Chunk"