2

I have used more than 15 Handlers in a timing being executed one gets over another on completion.I get java.lang.OutOfMemoryError: thread creation failed in the log and the app crashes,the code runs fine for the first time and gets crashes in the second time due to this issue how can I resolve this.Please help with this issue.Thanks.

MY log is

 08-09 13:36:12.125: E/AndroidRuntime(1473): FATAL EXCEPTION: main
08-09 13:36:12.125: E/AndroidRuntime(1473): java.lang.OutOfMemoryError: thread creation failed
08-09 13:36:12.125: E/AndroidRuntime(1473):     at java.lang.VMThread.create(Native Method)
08-09 13:36:12.125: E/AndroidRuntime(1473):     at java.lang.Thread.start(Thread.java:1232)
08-09 13:36:12.125: E/AndroidRuntime(1473):     at java.util.Timer$TimerImpl.<init>(Timer.java:192)
08-09 13:36:12.125: E/AndroidRuntime(1473):     at java.util.Timer.<init>(Timer.java:369)
08-09 13:36:12.125: E/AndroidRuntime(1473):     at java.util.Timer.<init>(Timer.java:389)
08-09 13:36:12.125: E/AndroidRuntime(1473):     at java.util.Timer.<init>(Timer.java:396)
08-09 13:36:12.125: E/AndroidRuntime(1473):     at com.CarBuyCo.Slotter.rollerstopthree(Slotter.java:655)*
08-09 13:36:12.125: E/AndroidRuntime(1473):     at com.CarBuyCo.Slotter$32.run(Slotter.java:593)*
08-09 13:36:12.125: E/AndroidRuntime(1473):     at android.os.Handler.handleCallback(Handler.java:587)
08-09 13:36:12.125: E/AndroidRuntime(1473):     at android.os.Handler.dispatchMessage(Handler.java:92)
08-09 13:36:12.125: E/AndroidRuntime(1473):     at android.os.Looper.loop(Looper.java:130)
08-09 13:36:12.125: E/AndroidRuntime(1473):     at android.app.ActivityThread.main(ActivityThread.java:3687)
08-09 13:36:12.125: E/AndroidRuntime(1473):     at java.lang.reflect.Method.invokeNative(Native Method)
08-09 13:36:12.125: E/AndroidRuntime(1473):     at java.lang.reflect.Method.invoke(Method.java:507)
08-09 13:36:12.125: E/AndroidRuntime(1473):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
08-09 13:36:12.125: E/AndroidRuntime(1473):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
08-09 13:36:12.125: E/AndroidRuntime(1473):     at dalvik.system.NativeStart.main(Native Method)
Samir Mangroliya
  • 39,918
  • 16
  • 117
  • 134
Karthik
  • 4,943
  • 19
  • 53
  • 86
  • add logcat and also use of 15 handlers is bad practice... – Samir Mangroliya Aug 09 '12 at 10:00
  • I do agree with you of using 15 handlers is a bad practice is there any way to clear of this.. – Karthik Aug 09 '12 at 10:04
  • java.lang.OutOfMemoryError usually means that you are keeping some reference to object you don't need anymore and they are not garbage collected. LogCat logs will not help here and pasting a code has no sense either. See this thread to see what kind of tool you can use to detect problem: http://stackoverflow.com/a/8174268/1387438 – Marek R Aug 09 '12 at 10:40

0 Answers0