Android GCM MeasurementBrokerService 占用太多内存

Android GCM MeasurementBrokerService eats too much memory

我根据 latest tutorial from google 在我的项目中实现了推送通知。

我的应用有 2 个后台服务运行。

当我查看我的应用占用的 RAM 内存时,我看到(例如):
- 使用的总内存 117 Mb
- 应用程序使用的内存 13 Mb
- Google 播放服务 (com.google.android.gms) - 104 Mb (!).
下面写着,服务 MeasurementBrokerService 正在使用中。

我做错了什么?
为什么推送通知需要这么多内存? 这是什么 MeasurementBrokerService,是否可以禁用它?

你可以试试这个,

在您的 AndroidManifest 的开头添加此行:xmlns:tools="http://schemas.android.com/tools"

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="cl.datacomputer.alejandrob.example"
   xmlns:tools="http://schemas.android.com/tools">

并在应用程序内部添加此服务标签:

<application
    android:name="android.support.multidex.MultiDexApplication"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"
    android:screenOrientation="portrait">

    <service android:name="com.google.android.gms.measurement.AppMeasurementService"
        tools:replace="android:enabled"
        android:enabled="false"
        android:exported="false"/>

这不是一个好的解决方案,我知道,但您可以禁用导致内存泄漏的服务。

对不起,如果我的英语不好。

此致。

亚历杭德罗布尔戈斯。

此处重复问题:"Service MeasurementBrokerService is in use" is showing in my application process

这是我对这两个问题的回答。

我通过删除

摆脱了这项服务和其他一些服务
NotificationCompat.Builder
...
startForeground(mNotificationId, notificationBuilder.build());

来自我的后台服务。

出于某种原因。 Alejandros 解决方案对我不起作用。