how to solve java.lang.OutOfMemoryError ?

You must Login before you can answer or comment on any questions.

Good afternoon, i've been experiencing this problem after the app open up to 3 or more page. and the errors are as below. I've tried edit the max vm heap application heap size but it didnt help. Using : Titanium sdk 2.1.3 android emulator 4.1.3 titanium alloy

[ERROR][TiApplication(  738)] (main) [8467,63133] Sending event: exception on thread: main msg:java.lang.OutOfMemoryError; Titanium 2.1.3,2012/10/02 16:16,15997d0
[ERROR][TiApplication(  738)] java.lang.OutOfMemoryError
[ERROR][TiApplication(  738)]   at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
[ERROR][TiApplication(  738)]   at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:527)
[ERROR][TiApplication(  738)]   at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:353)
[ERROR][TiApplication(  738)]   at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:781)
[ERROR][TiApplication(  738)]   at android.graphics.drawable.Drawable.createFromStream(Drawable.java:741)
[ERROR][TiApplication(  738)]   at org.appcelerator.titanium.util.TiUIHelper.loadFastDevDrawable(TiUIHelper.java:782)
[ERROR][TiApplication(  738)]   at org.appcelerator.titanium.util.TiUIHelper.getResourceDrawable(TiUIHelper.java:794)
[ERROR][TiApplication(  738)]   at org.appcelerator.titanium.util.TiFileHelper.loadDrawable(TiFileHelper.java:279)
[ERROR][TiApplication(  738)]   at org.appcelerator.titanium.util.TiUIHelper.buildBackgroundDrawable(TiUIHelper.java:494)
[ERROR][TiApplication(  738)]   at org.appcelerator.titanium.util.TiUIHelper.buildBackgroundDrawable(TiUIHelper.java:545)
[ERROR][TiApplication(  738)]   at org.appcelerator.titanium.view.TiUIView.handleBackgroundImage(TiUIView.java:911)
[ERROR][TiApplication(  738)]   at org.appcelerator.titanium.view.TiUIView.processProperties(TiUIView.java:659)
[ERROR][TiApplication(  738)]   at ti.modules.titanium.ui.widget.TiView.processProperties(TiView.java:49)
[ERROR][TiApplication(  738)]   at org.appcelerator.kroll.KrollProxy.setModelListener(KrollProxy.java:891)
[ERROR][TiApplication(  738)]   at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:442)
[ERROR][TiApplication(  738)]   at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:434)
[ERROR][TiApplication(  738)]   at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:412)
[ERROR][TiApplication(  738)]   at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:449)
[ERROR][TiApplication(  738)]   at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:434)
[ERROR][TiApplication(  738)]   at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:412)
[ERROR][TiApplication(  738)]   at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:449)
[ERROR][TiApplication(  738)]   at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:434)
[ERROR][TiApplication(  738)]   at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:412)
[ERROR][TiApplication(  738)]   at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:449)
[ERROR][TiApplication(  738)]   at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:434)
[ERROR][TiApplication(  738)]   at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:412)
[ERROR][TiApplication(  738)]   at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:449)
[ERROR][TiApplication(  738)]   at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:434)
[ERROR][TiApplication(  738)]   at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:412)
[ERROR][TiApplication(  738)]   at org.appcelerator.titanium.proxy.TiViewProxy.handleAdd(TiViewProxy.java:528)
[ERROR][TiApplication(  738)]   at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:205)
[ERROR][TiApplication(  738)]   at android.os.Handler.dispatchMessage(Handler.java:95)
[ERROR][TiApplication(  738)]   at android.os.Looper.loop(Looper.java:137)
[ERROR][TiApplication(  738)]   at android.app.ActivityThread.main(ActivityThread.java:4745)
[ERROR][TiApplication(  738)]   at java.lang.reflect.Method.invokeNative(Native Method)
[ERROR][TiApplication(  738)]   at java.lang.reflect.Method.invoke(Method.java:511)
[ERROR][TiApplication(  738)]   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
[ERROR][TiApplication(  738)]   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
[ERROR][TiApplication(  738)]   at dalvik.system.NativeStart.main(Native Method)
[ERROR][AndroidRuntime(  738)] FATAL EXCEPTION: main

— asked 7 months ago by Tee G
0 Comments

1 Answer

Accepted Answer

Are you using lots of images, or very large images? The log seems to indicate that it's failing when doing bitmap operations. I've seen this in the emulator from time to time. I'm betting you don't encounter the same issue on device. You may want to allocate more resources for your emulator.

— answered 7 months ago by Tony Lukasavage
answer permalink
1 Comment
  • yes, i use quite lots of images. After re-sized the images and add more resources to the emluator, the problem is solved. Thank you. =)

    — commented 7 months ago by Tee G

Your Answer

Think you can help? Login to answer this question!