You will find on this page a section as well as three tutorials explaining how to use the Handlers and in particular how to avoid memory leaks by linking the lifecycle of your thread to your activity.
In fact, if you do not note when your activity is destroyed (passage by the onDestroy method) your Thread is not... She became an orphan; You cannot communicate with it. Worse, it points to your Handler that is associated with the activity. Thus the Garbage Collector detects that these three objects are still "used" and only picks up crumb not. And this is the memory leak.


I wish you a good read, a good download and a good understanding of the use of the Handlers.

Download tutorials


These tutorials demonstrate how to use the handlers.

Each tutorial is an Eclipse project zipped, directly importable into your workspace.

Download in a single file all these tutorials:

Download them all

Demonstration of
the memory leak
Handler Tutorial
with AtomicBoolean
Handler Tutorial with
onRetainNonConfiguration
HandlerMemoryLeakDemo HandlerTuto HandlerActivityBindingThreadTuto

Download

Download

Download

AsyncTask Tutorial
with AtomicBoolean
Demonstration of
the memory leak
AsyncTask
AsyncTaskTuto OrphanAsyncTaskThreadTuto

Download

Download

Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Affichage
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline