5

I have an Android app that uses a timer to call an AsyncTask every 5-10 seconds (using java.util.Timer and java.util.TimerTask). The AsyncTask gets image data from an Amazon AWS S3 database, and loads an ImageView for the main UI Activity.

This works fine for an hour or two, but then I get a cryptic error message and the app gets killed. The error message comes from "Looper" and says either:

Could not create epoll instance.  errno=24

or

Could not create wake pipe

A search on the web seems to indicate the problem may have something to do with file descriptors (too many open file descriptors ?). I've gone through the code, but don't see any place where files, streams, or connections aren't closed.

When the app is killed, logcat has a message from AndroidRuntime that says:

FATAL EXCEPTION: main

Does anyone have a clue about these messages, or how to fix? Thank you!

gcl1
  • 4,070
  • 11
  • 38
  • 55
  • There is a lot of code, and I'm not sure which parts might be causing the error. I'm mostly looking for any clues as to what might be causing an error message like this. Thanks. – gcl1 Oct 30 '12 at 14:16
  • I suspect the internet is right about file descriptors, post the part that the timer invokes. – Wug Oct 30 '12 at 14:24
  • My assumption: This Is cause by the Timer! so what happened is that the looper is running for too long and used too many resources which might be preventing garbage collector, this is my assumption. – Wale Oct 03 '18 at 21:40

2 Answers2

0

possible memory leak. Use Leakcanary to detect which exact part of the code is creating this.

Raulp
  • 7,758
  • 20
  • 93
  • 155
-1

I got the same bug in my code when I used an alarm to trigger a task too quickly.

I fixed it by changing my code so that it only got added to the alarm to be run again after the average run time of the method (plus a little extra time just in case). If you add tasks more quickly than they finish executing then you'll fill up the Looper eventually which throws the error.

Essentially all that a Looper is is a queue of things to be run by the thread from my understanding.

joran
  • 169,992
  • 32
  • 429
  • 468
HansReich
  • 331
  • 1
  • 3