0

i am a complete newbie at this, but can anyone help or point me to a solution, been trying for 4 days, to stop the app crashing, app works great but crashing when refreshed, this is being tested on galaxy s3 & s5 and acer tablet Here is my Logcat

01-25 17:32:21.571: E/AndroidRuntime(14391): FATAL EXCEPTION: Thread-1310
01-25 17:32:21.571: E/AndroidRuntime(14391): Process: com.uktheatres, PID: 14391
01-25 17:32:21.571: E/AndroidRuntime(14391): java.lang.OutOfMemoryError
01-25 17:32:21.571: E/AndroidRuntime(14391):    at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:94)
01-25 17:32:21.571: E/AndroidRuntime(14391):    at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:145)
01-25 17:32:21.571: E/AndroidRuntime(14391):    at java.lang.StringBuilder.append(StringBuilder.java:216)
01-25 17:32:21.571: E/AndroidRuntime(14391):    at com.uktheatres.BT_fileManager.readTextFileFromAssets(BT_fileManager.java:371)
01-25 17:32:21.571: E/AndroidRuntime(14391):    at com.uktheatres.BT_fragment_load_config_data$3.run(BT_fragment_load_config_data.java:148)
01-25 17:32:21.601: W/ZZ(14391): BT_activity_host:onPause
01-25 17:32:22.341: W/ZZ(14391): uktheatres_appDelegate: onTrimMemory with level: 20
01-25 17:32:22.351: W/ZZ(14391): BT_activity_host:onStop
01-25 17:32:22.351: W/ZZ(14391): BT_activity_host:onDestroy
01-25 17:32:22.361: E/WindowManager(14391): android.view.WindowLeaked: Activity com.uktheatres.BT_activity_host has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{21f7ec58 V.E..... R.....ID 0,0-580,162} that was originally added here
01-25 17:32:22.361: E/WindowManager(14391):     at android.view.ViewRootImpl.<init>(ViewRootImpl.java:348)
01-25 17:32:22.361: E/WindowManager(14391):     at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:248)
01-25 17:32:22.361: E/WindowManager(14391):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
01-25 17:32:22.361: E/WindowManager(14391):     at android.app.Dialog.show(Dialog.java:286)
01-25 17:32:22.361: E/WindowManager(14391):     at android.app.ProgressDialog.show(ProgressDialog.java:116)
01-25 17:32:22.361: E/WindowManager(14391):     at android.app.ProgressDialog.show(ProgressDialog.java:99)
01-25 17:32:22.361: E/WindowManager(14391):     at com.uktheatres.BT_fragment.showProgress(BT_fragment.java:306)
01-25 17:32:22.361: E/WindowManager(14391):     at com.uktheatres.BT_fragment_load_config_data.loadAppConfigDataAfterDelay(BT_fragment_load_config_data.java:102)
01-25 17:32:22.361: E/WindowManager(14391):     at com.uktheatres.BT_fragment_load_config_data.onCreateView(BT_fragment_load_config_data.java:88)
01-25 17:32:22.361: E/WindowManager(14391):     at android.app.Fragment.performCreateView(Fragment.java:1700)
01-25 17:32:22.361: E/WindowManager(14391):     at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:890)
01-25 17:32:22.361: E/WindowManager(14391):     at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062)
01-25 17:32:22.361: E/WindowManager(14391):     at android.app.BackStackRecord.run(BackStackRecord.java:684)
01-25 17:32:22.361: E/WindowManager(14391):     at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1447)
01-25 17:32:22.361: E/WindowManager(14391):     at android.app.FragmentManagerImpl$1.run(FragmentManager.java:443)
01-25 17:32:22.361: E/WindowManager(14391):     at android.os.Handler.handleCallback(Handler.java:733)
01-25 17:32:22.361: E/WindowManager(14391):     at android.os.Handler.dispatchMessage(Handler.java:95)
01-25 17:32:22.361: E/WindowManager(14391):     at android.os.Looper.loop(Looper.java:149)
01-25 17:32:22.361: E/WindowManager(14391):     at android.app.ActivityThread.main(ActivityThread.java:5061)
01-25 17:32:22.361: E/WindowManager(14391):     at java.lang.reflect.Method.invokeNative(Native Method)
01-25 17:32:22.361: E/WindowManager(14391):     at java.lang.reflect.Method.invoke(Method.java:515)
01-25 17:32:22.361: E/WindowManager(14391):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
01-25 17:32:22.361: E/WindowManager(14391):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:603)
01-25 17:32:22.361: E/WindowManager(14391):     at dalvik.system.NativeStart.main(Native Method)
Bhavik Mehta
  • 573
  • 8
  • 21

1 Answers1

1

what you are getting is OutOfMemorException and that means

The exception that is thrown when there is not enough memory to continue the execution of a program.

on possible way can be break your file in to small pieces

or what you can do is to check the avaliable memory before you load the file

So the most efficient way to handle OutOfMemoryException is to architecture your application in such a way that it never attempts to load lots of data into memory in order to avoid the exception.

Moubeen Farooq Khan
  • 2,875
  • 1
  • 11
  • 26
  • Thanks for your advice guys, im using buzztouch for code, the app is looking for the config file when it refreshes, which is quite large (4mb) as the app has over 5000 screens, everything works great in the ios version, but the android one crashes on refresh, not all devices, just certain ones, i don't think there's any way of reducing the config file, how do i check the available memory and how do i change the amount of data into memory, remember im a newbie at this, so an idiots guide if poss guys :) – Sean Sullivan Jan 26 '15 at 10:44
  • check these link they might help you http://stackoverflow.com/questions/2630158/detect-application-heap-size-in-android .... http://stackoverflow.com/questions/3170691/how-to-get-current-memory-usage-in-android . ....... http://stackoverflow.com/questions/2298208/how-do-i-discover-memory-usage-of-my-application-in-android ... http://stackoverflow.com/questions/4820353/how-do-i-detect-the-heap-size-usage-of-an-android-application – Moubeen Farooq Khan Jan 26 '15 at 19:23
  • your a star, many thanks, changed the option in manifest to large heap yes, and all the crashes stopped, – Sean Sullivan Jan 27 '15 at 11:32
  • @SeanSullivan if you are satisfied with my answer kindly mark it as a tik.. Thanks – Moubeen Farooq Khan Jan 27 '15 at 11:49