Define when the object should die
Choose a screen, task or resource with a clear lifecycle. Open it, perform the operation, close it and repeat under the same conditions.
The memory-management guide explains why managed memory is reclaimed only when objects are no longer reachable. Calling garbage collection is not a fix for a live reference held by your code.
Follow the retaining path
Use the Memory Profiler or an appropriate leak-detection workflow to inspect why the object is still reachable.
| Retainer | Typical correction |
|---|---|
| Singleton holding an activity | Store an appropriate longer-lived dependency instead |
| Listener not removed | Match registration to lifecycle cleanup |
| Long-running callback | Cancel or detach when its owner ends |
| Unbounded collection/cache | Bound entries and define eviction |
| Native resource | Release according to the native API contract |
The correct fix depends on ownership, not simply on making fields weak references.
Avoid indiscriminate weak references
A weak reference can hide a retention symptom while creating nondeterministic missing-state behavior. Prefer clear ownership and cancellation first. Use weak references only where the API and lifecycle design justify them.
Check repeated navigation and recreation
Test rotation, back navigation, repeated feature entry and process-related restoration. A screen that leaks only through one error callback may look healthy during the happy path.
Compare retained instances after the lifecycle should have completed. Allow for legitimate asynchronous cleanup and document the observation window.
Verify both memory and behavior
After removing the retaining path, make sure callbacks still arrive for active owners and resources are not released too early. APKLint's Performance Checker can organize the review, but it cannot inspect a live heap from an APK. Keep the reference path, expected lifetime and before/after repeated-flow evidence with the fix.
Sources and further reading
Reference review: 22 September 2026. Examples illustrate the workflow; check your installed versions, release artifact and account-specific Console requirements before applying them. This guide is not a claim that APKLint executed your project or verified your private account.



