java.lang.OutOfMemoryError:

Anyone know anything more about this error?

I’ve an app that is giving this error 1% of users:

java.lang.OutOfMemoryError: at dalvik.system.VMRuntime.newNonMovableArray (Native Method) at android.graphics.BitmapFactory.nativeDecodeAsset (Native Method) at android.graphics.BitmapFactory.decodeStream (BitmapFactory.java:726) at android.graphics.BitmapFactory.decodeResourceStream (BitmapFactory.java:547) at android.graphics.BitmapFactory.decodeResource (BitmapFactory.java:575) at android.graphics.BitmapFactory.decodeResource (BitmapFactory.java:605) at com.ansca.corona.CoronaActivity.showCoronaSplashScreen (CoronaActivity.java:2082) at com.ansca.corona.CoronaActivity.onCreate (CoronaActivity.java:242) at android.app.Activity.performCreate (Activity.java:6289) at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1119) at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2655) at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2767) at android.app.ActivityThread.access$900 (ActivityThread.java:177) at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1449) at android.os.Handler.dispatchMessage (Handler.java:102) at android.os.Looper.loop (Looper.java:145) at android.app.ActivityThread.main (ActivityThread.java:5951) at java.lang.reflect.Method.invoke (Native Method) at java.lang.reflect.Method.invoke (Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1400) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1195)

That means that your app was using to much memory. I had this before as well. There was a memory leak which caused a hugh increase in memory consumed by my app. Did a full review of my code and eventually fixed it.

There is a setting for build.settings to ask the device for more reserved memory for your app but that will not fix the problem only be a plaster while fixing the actual problem.

settings=
{
    android=
    {
        largeHeap=true,
    },
}

What plugins are you using?

Edit: I just looked at the memory issue that I have and realized that in your case @pijappi is 100% correct.

Thanks for the help guys, i guess i will need to review all my code :confused:

Check the crash logs and look at the devices raising them… I get issues with devices that are under 1GB RAM if they have lots of apps open and my game wants 300MB+

From the trace it looks like the crash is on start up (I see a reference to the Corona splash screen) are you using the default or have you maybe got a huge PNG loading?  Try exporting the PNG again and make sure you are using the basic RGB profile as that could cause crashes on older/cheaper devices.

the device is getting this crash is a samsung s4 with android 5. 2Gb RAM. it had 3 crashes same day.

the spash screen image is a .jpg with 218k (1440x2280) maybe resolution is the problem because texture memory 2048 limit devices? i will convert it to png 8bit with no transparency and reduce the image to half the size.

pijappi, i will try your advice also, thx.

*edit*

after some testing. i didn’t found any memory leaking.

i’ve check in all my scenes. the max memory i could get was:

---------MEMORY USAGE INFORMATION---------

System Memory Used: 2.372 Mb

Texture Memory Used: 48.323 Mb


it will eventually go down to 1Mb, 20Mb texture memory…and go up…go down…it will never pass this value…

i entered all my diferent scenes more than 100 times.

Is there a reason your splash screen is so large?

Can you just a centered logo, say 1024x1024?  You may need to match your image to the default background color.

Rob

the splash screen is not an logo it’s an complex background image with more than 50 elements…tell that to the designer that choose that background.

What leads you to that conclusion @carloscosta?  Looking at the Native App template, it’s a single PNG file that’s 1432x600 in size with a black background behind the text. I don’t see any reason simulator builds would use anything different.

Rob

That means that your app was using to much memory. I had this before as well. There was a memory leak which caused a hugh increase in memory consumed by my app. Did a full review of my code and eventually fixed it.

There is a setting for build.settings to ask the device for more reserved memory for your app but that will not fix the problem only be a plaster while fixing the actual problem.

settings=
{
    android=
    {
        largeHeap=true,
    },
}

What plugins are you using?

Edit: I just looked at the memory issue that I have and realized that in your case @pijappi is 100% correct.

Thanks for the help guys, i guess i will need to review all my code :confused:

Check the crash logs and look at the devices raising them… I get issues with devices that are under 1GB RAM if they have lots of apps open and my game wants 300MB+

From the trace it looks like the crash is on start up (I see a reference to the Corona splash screen) are you using the default or have you maybe got a huge PNG loading?  Try exporting the PNG again and make sure you are using the basic RGB profile as that could cause crashes on older/cheaper devices.

the device is getting this crash is a samsung s4 with android 5. 2Gb RAM. it had 3 crashes same day.

the spash screen image is a .jpg with 218k (1440x2280) maybe resolution is the problem because texture memory 2048 limit devices? i will convert it to png 8bit with no transparency and reduce the image to half the size.

pijappi, i will try your advice also, thx.

*edit*

after some testing. i didn’t found any memory leaking.

i’ve check in all my scenes. the max memory i could get was:

---------MEMORY USAGE INFORMATION---------

System Memory Used: 2.372 Mb

Texture Memory Used: 48.323 Mb


it will eventually go down to 1Mb, 20Mb texture memory…and go up…go down…it will never pass this value…

i entered all my diferent scenes more than 100 times.

Is there a reason your splash screen is so large?

Can you just a centered logo, say 1024x1024?  You may need to match your image to the default background color.

Rob

the splash screen is not an logo it’s an complex background image with more than 50 elements…tell that to the designer that choose that background.

What leads you to that conclusion @carloscosta?  Looking at the Native App template, it’s a single PNG file that’s 1432x600 in size with a black background behind the text. I don’t see any reason simulator builds would use anything different.

Rob