Reputation: 21
I created a blank Android Wear 2.0 stand-alone app project in Android Studio. I noticed that when I run the blank app on my watch there seems to be a memory leak (shown below). Is anyone else experiencing this issue?
The device I'm testing it on is an LG Watch Style, running Android Wear 2.0
This is a blank project, here is the code:
MainActivity.java
import android.os.Bundle;
import android.support.wearable.activity.WearableActivity;
public class MainActivity extends WearableActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mc.memorytester">
<uses-feature android:name="android.hardware.type.watch"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@android:style/Theme.DeviceDefault">
<uses-library
android:name="com.google.android.wearable"
android:required="false"/>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.DeviceDefault.Light">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.mc.memorytester"
minSdkVersion 25
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.support:wearable:2.0.3'
compile 'com.google.android.gms:play-services-wearable:11.0.4'
provided 'com.google.android.wearable:wearable:2.0.3'
}
Upvotes: 0
Views: 187
Reputation: 4784
This doesn't look like a memory leak. If you were in fact leaking, the total amount of used memory would keep increasing over time, and eventually cause a very sluggish experience and/or an OutOfMemoryException
. What you see here are cycles of objects being created, and then garbage collected.
There are still things you can do to improve this, since frequent garbage collection might result in hiccups/lag.
My suggestion is to take a look at methods that are executed often (onDraw()
and similar things) and make sure that you're not creating objects inside of them. If that doesn't help you can use the Android Profiler to dig deeper and find out what's being created (details about how you do that can be found e.g. here)
Upvotes: 1