MemoryLeak can occur for many reasons, some common reasons:
- Keep a reference to your object (in this case, an instance of your dialog box) in some static fields .
- Pass
Context to Thread or AsyncTask , because Threads are also GC root strong>! - Your class has a non-static inner class, in which case a memory leak occurs if the inner class is associated with GC root (for example, if the inner class is an
AsyncTask instance).
In your case, perhaps you have a view related to GC root, while this view cannot be garbage collected, your dialog box in which the views are saved cannot be garbage collected either.
source share