0

I've found that my problem have been report many times on Internet, but I do not found any correct explanantion about it.

On my Galaxy Note, when I exit from my program, I have some time this kind of message into le logcat.

threadid=3: reacting to signal 3
Wrote stack traces to '/data/anr/traces.txt'

I can't acces to the file. DDMS view does not show me anything into the Explorer.

I read on Internet that ANR (Application Not Responding) was due to Activity long process. But in my case, my activity does not do any special things.

I'm using a SurfaceView that launch 3 Threads. One of them can take a long time (1 or 2 seconds) at the beginnig of the application (it read's big data files from sdcard), but it does not do anything at the end when I exit.

I can see 10 process into DDMS view, but I do not know what thread is the #3 ! So I do not know if it's one of the thread I launch or if this is a Android thread.

More than finding the problem, I'd like to understand what is signal 3. When this king of problem happened. Is it only due to a process that not responding or can it be due to another problem ? I tested my native code under linux (beagleboard). There is no memory leak and no segmentation fault. Why does this problem happened only when I exit my application (and only sometimes). Does it mean that my thread destruction is not correct ?

I'm using this code

public void surfaceDestroyed(SurfaceHolder holder) {
    boolean retry = true;
    while (retry) {
        try {
            thread.join();
            retry = false;
        } catch (InterruptedException e) {
            // try again shutting down the thread
        }
    }
}

I also have a special code into onDestroy of my Activity.

This code make some native Code free. Because it's c++ code, it call all the destructor of my objects. I don't know if this destrution is long, but I suppose it must not take more than 1 ms.

Well. I've work on this problem for 1 week now. The next step for me if I do not understand the problem will be to restart a new projet and import my code, part by part to check when the problem really occured.

webshaker
  • 467
  • 6
  • 17
  • For crash file you can probably look this post http://stackoverflow.com/questions/5467972/how-to-access-android-files-data-anr-traces-txt-and-data-tombstones-tombstones – Piyush Patel Dec 13 '11 at 10:25

1 Answers1

0

Well. I've started a new project, And I found some informations! Thread #3 might be the Garbage collector Thread. It seem's that the problem occured on exit when the GC do something with the malloc I've made into my native code.

I changed all my code and just made a big C++ malloc (20Mo) into the OnCreate of the activity. And a free into OnDestroy. After some exit and restart, I have the problem. I do not know what is the link between CG and native C malloc, but I guess that after some start the malloc failed, because th GC process do not have enough time to clean the native buffer...

Actually no crash. Sometime the application take few seconds to start but the phone do not crash.

This is possible that I do not test every where the result of my malloc calls, so my problem could comes from a failed malloc. I will check again.

webshaker
  • 467
  • 6
  • 17