0

我已经实现了一个简单的后台服务类,它只包含一个 Toast 消息。但它大约需要 16-20mb,尽管还有其他进程只需要 1-3mb。

这是我的服务类代码

public class BackgroundClipListener extends Service {

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Toast.makeText(this, "Service Started", Toast.LENGTH_SHORT).show();
        return super.onStartCommand(intent, flags, startId);
    }
}

这是内存使用情况。

没有其他应用程序正在运行 其他进程列表 我的服务

如果有人能描述我为什么我的服务占用这么多内存或者我如何改进我的代码,那将非常有帮助。

4

0 回答 0