Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorr.kuznetsov <r.kuznetsov@corp.mail.ru>2016-07-21 17:57:06 +0300
committerr.kuznetsov <r.kuznetsov@corp.mail.ru>2016-07-21 17:57:06 +0300
commit81e6bd26f7fc02e6fb4023c7f1e9555376e82573 (patch)
treee7d8f0045d25853ca9f9cee243260194fa3da000 /android
parent154c2171e60886ad67be6875f7755e23bd966c21 (diff)
Fixed mem leaks on Android
Diffstat (limited to 'android')
-rw-r--r--android/jni/com/mapswithme/platform/Platform.cpp6
-rw-r--r--android/src/com/mapswithme/util/statistics/PushwooshHelper.java12
2 files changed, 11 insertions, 7 deletions
diff --git a/android/jni/com/mapswithme/platform/Platform.cpp b/android/jni/com/mapswithme/platform/Platform.cpp
index 56c61df873..bc327c46eb 100644
--- a/android/jni/com/mapswithme/platform/Platform.cpp
+++ b/android/jni/com/mapswithme/platform/Platform.cpp
@@ -206,10 +206,8 @@ namespace android
return;
JNIEnv * env = jni::GetEnv();
- if (env == nullptr)
- return;
-
- env->CallVoidMethod(m_functorProcessObject, m_sendPushWooshTagsMethod, jni::ToJavaString(env, tag),
+ env->CallVoidMethod(m_functorProcessObject, m_sendPushWooshTagsMethod,
+ jni::TScopedLocalRef(env, jni::ToJavaString(env, tag)).get(),
jni::TScopedLocalObjectArrayRef(env, jni::ToJavaStringArray(env, values)).get());
}
} // namespace android
diff --git a/android/src/com/mapswithme/util/statistics/PushwooshHelper.java b/android/src/com/mapswithme/util/statistics/PushwooshHelper.java
index 55cbb9a980..bf4f27deb5 100644
--- a/android/src/com/mapswithme/util/statistics/PushwooshHelper.java
+++ b/android/src/com/mapswithme/util/statistics/PushwooshHelper.java
@@ -10,6 +10,7 @@ import com.mapswithme.maps.Framework;
import com.pushwoosh.PushManager;
import com.pushwoosh.SendPushTagsCallBack;
+import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
@@ -22,7 +23,8 @@ public final class PushwooshHelper implements SendPushTagsCallBack
private static final PushwooshHelper sInstance = new PushwooshHelper();
- private Context mContext;
+ private WeakReference<Context> mContext;
+
private final Object mSyncObject = new Object();
private AsyncTask<Void, Void, Void> mTask;
private List<Map<String, Object>> mTagsQueue = new LinkedList<>();
@@ -35,7 +37,7 @@ public final class PushwooshHelper implements SendPushTagsCallBack
{
synchronized (mSyncObject)
{
- mContext = context;
+ mContext = new WeakReference<>(context);
}
}
@@ -85,7 +87,11 @@ public final class PushwooshHelper implements SendPushTagsCallBack
@Override
protected Void doInBackground(Void... params)
{
- PushManager.sendTags(mContext, tagsToSend, PushwooshHelper.this);
+ final Context context = mContext.get();
+ if (context == null)
+ return null;
+
+ PushManager.sendTags(context, tagsToSend, PushwooshHelper.this);
return null;
}
};