jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/372847 )

Change subject: Prevent possible memory leak in OfflineManager.
......................................................................


Prevent possible memory leak in OfflineManager.

When searchForCompilations() is invoked, the Callback that is passed into
it can be an anonymous class belonging to an Activity.  When the
searchTask completes, it can technically hold on to a reference of
Callback indefinitely.

This patch explicitly sets searchTask to null as soon as the task itself
finishes, so that any references to the Callback (and thus references to
an Activity) are not held for longer than necessary.

Change-Id: I197dbabadae59bd93d1ac6e3adf49a2e4fd76acc
---
M app/src/main/java/org/wikipedia/offline/OfflineManager.java
1 file changed, 2 insertions(+), 0 deletions(-)

Approvals:
  jenkins-bot: Verified
  Mholloway: Looks good to me, approved



diff --git a/app/src/main/java/org/wikipedia/offline/OfflineManager.java 
b/app/src/main/java/org/wikipedia/offline/OfflineManager.java
index e51c91d..9bbbc97 100644
--- a/app/src/main/java/org/wikipedia/offline/OfflineManager.java
+++ b/app/src/main/java/org/wikipedia/offline/OfflineManager.java
@@ -56,6 +56,7 @@
         lastSearchTime = System.currentTimeMillis();
         searchTask = new CompilationSearchTask() {
             @Override public void onFinish(List<Compilation> results) {
+                searchTask = null;
                 if (isCancelled()) {
                     return;
                 }
@@ -81,6 +82,7 @@
             }
 
             @Override public void onCatch(Throwable caught) {
+                searchTask = null;
                 L.e("Error while searching for compilations.", caught);
                 callback.onError(caught);
             }

-- 
To view, visit https://gerrit.wikimedia.org/r/372847
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I197dbabadae59bd93d1ac6e3adf49a2e4fd76acc
Gerrit-PatchSet: 1
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Dbrant <[email protected]>
Gerrit-Reviewer: Brion VIBBER <[email protected]>
Gerrit-Reviewer: Mholloway <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to