Articles in this section
Category / Section

How to resolve out of memory exception when loading large images in Android?

1 min read

When you try to load large size images in image editor in Android, you may get out of memory exception because this application cannot handle large size images. You can resolve this exception by using the following two ways:

 

Methods to resolve out of memory exception

 

1. Set largeHeap value as true in Android project.

2. Set largeHeap size for application.

 

How to set largeHeap value as true in Android project?

 

Code Snippet

 

To set largeHeap  value as true in Android project, refer the following code snippet.

 
<manifest xmlns:android=http://schemas.android.com/apk/res/android
          android:installLocation="preferExternal">
      <uses-sdk android:minSdkVersion="15" />
      <application android:label="ImageEditor_GettingStarted.Android" 
        android:largeHeap="true"></application>
</manifest> 

 

 

To set largeHeap value as true, refer the following steps:
 

Step 1: Expand properties tab in Android project.

 

C:\Users\samkumar.arivazhagan\AppData\Local\Microsoft\Windows\INetCache\Content.Word\Manifest.png

 

Step 2: In AndroidManifest.xml file, set largeHeap value as true. Please refer the following screenshot for better understanding.

 

C:\Users\samkumar.arivazhagan\AppData\Local\Microsoft\Windows\INetCache\Content.Word\Manifest.png

 

How to set largeHeap size in application?

 

To set largeHeap size in application, follow the below steps:

Step 1: Right-click the Android project, and then select Properties.

 

C:\Users\samkumar.arivazhagan\AppData\Local\Microsoft\Windows\INetCache\Content.Word\properties.png

 

 

 

 

 

 

 

 

 

Step 2: In Android options, select Advance and set Java Max Heap size as 1G.

 

C:\Users\samkumar.arivazhagan\AppData\Local\Microsoft\Windows\INetCache\Content.Word\1G.PNG



 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied