Android: Error: java.lang.OutOfMemoryError:


#1

My app keeps crashing with Error: java.lang.OutOfMemoryError:…Please how do I resolve this


#2

Were you able to get a stack trace from the console log?

Also is the issue happening on different pages or when you are doing a particular function?


#3

The first question should be if you are using Images?


#4

no please, the only images am using is my logo and background pattern file of size 4.10 kb


#5

Then you have to paste whole stacktrace here and describe some background. What you have to do in your app to reproduce problem?


#6

Java applications are only allowed to use a limited amount of memory. This limit is specified during application startup. Java heap space indicates object could not be allocated in the Java heap. With -Xmx you can configure more memory for you JVM. To be sure that you don’t leak or waste memory.

example

Starting a JVM like below will start it with 256MB of memory, and will allow the process to use up to 2048MB of memory:

java -Xmx2048m -Xms256m


#7

While the post is valid for the most part, the example is absolutely irrelevant in the context of Android applications and spawning JVMs with distinct limitations, since this is managed by the system in Android, and is not dictated the user, or the developer.