Byte[] And Java.lang.outofmemoryerror Read/write File By Bits
Solution 1:
OutOfMemoryError
Thrown when a request for memory is made that can not be satisfied using the available platform resources. Such a request may be made by both the running application or by an internal function of the VM(Virtual Machine)
when you get error like OutOfMemory
it means you are running out of memory for the application as your app consumes more space then allocated to it by the system.
put this attribute android:largeHeap="true"
in the the <application/>
atgin the manifest.xml
file
for example
<application
android:name="support.classes.StartUp"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"// you are increasing the heap space for the app
android:theme="@style/AppThemeTest">
if you simple want to free some space it would be better to let Android system handle it which knows the best
System.gc()
call garbage collector before you do any memory consuming task as that will free some space for you. if you try to call this after your task then it serves no purpose
Post a Comment for "Byte[] And Java.lang.outofmemoryerror Read/write File By Bits"