- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我有一个 MediaControllerCompat
,它是在建立 MediaSession
连接时创建的一个实例。完成此连接后,我按以下方式创建 MediaControllerCompat
:
MediaControllerCompat mediaController = new MediaControllerCompat(this, token);
MediaControllerCompat.setMediaController(this, mediaController);
token 是从MediaSession
获取的。
每次按下后退按钮都会检测到泄漏。我没有向 MediaControllerCompat
注册任何回调/监听器。我已经尝试在 Activity 的 onDestroy()
方法上将 MediaController
设置为 null,但没有成功。
MediaControllerCompat.setMediaController(this, null);
跟随 LeakCanary 日志。
D/LeakCanary: * com.me.PlaybackFullscreenActivity has leaked:
D/LeakCanary: * GC ROOT android.os.ResultReceiver$MyResultReceiver.this$0
D/LeakCanary: * references android.support.v4.media.session.MediaControllerCompat$MediaControllerImplApi21$1.this$0 (anonymous subclass of android.os.ResultReceiver)
D/LeakCanary: * references android.support.v4.media.session.MediaControllerCompat$MediaControllerImplApi23.mControllerObj
D/LeakCanary: * references android.media.session.MediaController.mContext
D/LeakCanary: * leaks com.me.ui.playback.PlaybackFullscreenActivity instance
D/LeakCanary: * Retaining: 54 KB.
D/LeakCanary: * Reference Key: 004ed9cd-c668-4d23-9ee6-cecad1b980a5
D/LeakCanary: * Device: unknown Android Android SDK built for x86_64 sdk_google_phone_x86_64
D/LeakCanary: * Android Version: 7.1 API: 25 LeakCanary: 1.5 00f37f5
D/LeakCanary: * Durations: watch=5018ms, gc=115ms, heap dump=1936ms, analysis=6011ms
D/LeakCanary: * Details:
D/LeakCanary: * Instance of android.os.ResultReceiver$MyResultReceiver
D/LeakCanary: | this$0 = android.support.v4.media.session.MediaControllerCompat$MediaControllerImplApi21$1@322318080 (0x13362f00)
D/LeakCanary: | mDescriptor = java.lang.String@1887101392 (0x707ae1d0)
D/LeakCanary: | mObject = -813433536
D/LeakCanary: | mOwner = android.os.ResultReceiver$MyResultReceiver@322318176 (0x13362f60)
D/LeakCanary: | shadow$_klass_ = android.os.ResultReceiver$MyResultReceiver
D/LeakCanary: | shadow$_monitor_ = 0
D/LeakCanary: * Instance of android.support.v4.media.session.MediaControllerCompat$MediaControllerImplApi21$1
D/LeakCanary: | this$0 = android.support.v4.media.session.MediaControllerCompat$MediaControllerImplApi23@322317952 (0x13362e80)
D/LeakCanary: | mHandler = android.os.Handler@322318144 (0x13362f40)
D/LeakCanary: | mLocal = true
D/LeakCanary: | mReceiver = android.os.ResultReceiver$MyResultReceiver@322318176 (0x13362f60)
D/LeakCanary: | shadow$_klass_ = android.support.v4.media.session.MediaControllerCompat$MediaControllerImplApi21$1
D/LeakCanary: | shadow$_monitor_ = 0
D/LeakCanary: * Instance of android.support.v4.media.session.MediaControllerCompat$MediaControllerImplApi23
D/LeakCanary: | mCallbackMap = java.util.HashMap@322587040 (0x133a49a0)
D/LeakCanary: | mControllerObj = android.media.session.MediaController@322587088 (0x133a49d0)
D/LeakCanary: | mExtraBinder = android.support.v4.media.session.MediaSessionCompat$MediaSessionImplApi21$ExtraSession@319823424 (0x13101e40)
D/LeakCanary: | mPendingCallbacks = null
D/LeakCanary: | shadow$_klass_ = android.support.v4.media.session.MediaControllerCompat$MediaControllerImplApi23
D/LeakCanary: | shadow$_monitor_ = 0
D/LeakCanary: * Instance of android.media.session.MediaController
D/LeakCanary: | static MSG_UPDATE_EXTRAS = 7
D/LeakCanary: | static MSG_DESTROYED = 8
D/LeakCanary: | static MSG_UPDATE_VOLUME = 4
D/LeakCanary: | static MSG_UPDATE_QUEUE_TITLE = 6
D/LeakCanary: | static MSG_UPDATE_PLAYBACK_STATE = 2
D/LeakCanary: | static $staticOverhead = byte[72]@317243393 (0x12e8c001)
D/LeakCanary: | static MSG_UPDATE_QUEUE = 5
D/LeakCanary: | static MSG_EVENT = 1
D/LeakCanary: | static TAG = java.lang.String@1886292312 (0x706e8958)
D/LeakCanary: | static MSG_UPDATE_METADATA = 3
D/LeakCanary: | mCallbacks = java.util.ArrayList@322318048 (0x13362ee0)
D/LeakCanary: | mCbRegistered = false
D/LeakCanary: | mCbStub = android.media.session.MediaController$CallbackStub@322317984 (0x13362ea0)
D/LeakCanary: | mContext = com.me.ui.playback.PlaybackFullscreenActivity@322837504 (0x133e1c00)
D/LeakCanary: | mLock = java.lang.Object@319489728 (0x130b06c0)
D/LeakCanary: | mPackageName = null
D/LeakCanary: | mSessionBinder = android.media.session.ISessionController$Stub$Proxy@319491728 (0x130b0e90)
D/LeakCanary: | mTag = null
D/LeakCanary: | mToken = android.media.session.MediaSession$Token@319489760 (0x130b06e0)
D/LeakCanary: | mTransportControls = android.media.session.MediaController$TransportControls@319489744 (0x130b06d0)
D/LeakCanary: | shadow$_klass_ = android.media.session.MediaController
D/LeakCanary: | shadow$_monitor_ = 0
D/LeakCanary: * Instance of com.me.ui.playback.PlaybackFullscreenActivity
D/LeakCanary: | static $staticOverhead = byte[16]@317706241 (0x12efd001)
D/LeakCanary: | static serialVersionUID = 0
D/LeakCanary: | static $change = null
D/LeakCanary: | mToolbar = android.support.v7.widget.Toolbar@321094656 (0x13238400)
D/LeakCanary: | playbackFragment = com.me.ui.playback.PlaybackFragment@318524080 (0x12fc4ab0)
D/LeakCanary: | mDelegate = android.support.v7.app.AppCompatDelegateImplV23@320052000 (0x13139b20)
D/LeakCanary: | mEatKeyUpEvent = false
D/LeakCanary: | mResources = null
D/LeakCanary: | mThemeId = 2131427393
D/LeakCanary: | mCreated = true
D/LeakCanary: | mFragments = android.support.v4.app.FragmentController@323740768 (0x134be460)
D/LeakCanary: | mHandler = android.support.v4.app.FragmentActivity$1@323839264 (0x134d6520)
D/LeakCanary: | mNextCandidateRequestIndex = 0
D/LeakCanary: | mOptionsMenuInvalidated = false
D/LeakCanary: | mPendingFragmentActivityResults = android.support.v4.util.SparseArrayCompat@323840160 (0x134d68a0)
D/LeakCanary: | mReallyStopped = true
D/LeakCanary: | mRequestedPermissionsFromFragment = false
D/LeakCanary: | mResumed = false
D/LeakCanary: | mRetaining = false
D/LeakCanary: | mStopped = true
D/LeakCanary: | mStartedActivityFromFragment = false
D/LeakCanary: | mStartedIntentSenderFromFragment = false
D/LeakCanary: | mExtraDataMap = android.support.v4.util.SimpleArrayMap@323839232 (0x134d6500)
D/LeakCanary: | mActionBar = null
D/LeakCanary: | mActionModeTypeStarting = 0
D/LeakCanary: | mActivityInfo = android.content.pm.ActivityInfo@319807616 (0x130fe080)
D/LeakCanary: | mActivityTransitionState = android.app.ActivityTransitionState@323795264 (0x134cb940)
D/LeakCanary: | mApplication = com.me.MainApplication@314898704 (0x12c4f910)
D/LeakCanary: | mCalled = true
D/LeakCanary: | mChangeCanvasToTranslucent = false
D/LeakCanary: | mChangingConfigurations = false
D/LeakCanary: | mComponent = android.content.ComponentName@323825776 (0x134d3070)
D/LeakCanary: | mConfigChangeFlags = 0
D/LeakCanary: | mCurrentConfig = android.content.res.Configuration@323855456 (0x134da460)
D/LeakCanary: | mDecor = null
D/LeakCanary: | mDefaultKeyMode = 0
D/LeakCanary: | mDefaultKeySsb = null
D/LeakCanary: | mDestroyed = true
D/LeakCanary: | mDoReportFullyDrawn = false
D/LeakCanary: | mEmbeddedID = null
D/LeakCanary: | mEnableDefaultActionBarUp = false
D/LeakCanary: | mEnterTransitionListener = android.app.SharedElementCallback$1@1888376616 (0x708e5728)
D/LeakCanary: | mExitTransitionListener = android.app.SharedElementCallback$1@1888376616 (0x708e5728)
D/LeakCanary: | mFinished = true
D/LeakCanary: | mFragments = android.app.FragmentController@323740720 (0x134be430)
D/LeakCanary: | mHandler = android.os.Handler@323839136 (0x134d64a0)
D/LeakCanary: | mIdent = 169286722
D/LeakCanary: | mInstanceTracker = android.os.StrictMode$InstanceTracker@323740736 (0x134be440)
D/LeakCanary: | mInstrumentation = android.app.Instrumentation@315044816 (0x12c733d0)
D/LeakCanary: | mIntent = android.content.Intent@323821632 (0x134d2040)
D/LeakCanary: | mLastNonConfigurationInstances = null
D/LeakCanary: | mMainThread = android.app.ActivityThread@314791872 (0x12c357c0)
D/LeakCanary: | mManagedCursors = java.util.ArrayList@323839168 (0x134d64c0)
D/LeakCanary: | mManagedDialogs = null
D/LeakCanary: | mMenuInflater = null
D/LeakCanary: | mParent = null
D/LeakCanary: | mReferrer = java.lang.String@323822208 (0x134d2280)
D/LeakCanary: | mResultCode = 0
D/LeakCanary: | mResultData = null
D/LeakCanary: | mResumed = false
D/LeakCanary: | mSearchEvent = null
D/LeakCanary: | mSearchManager = null
D/LeakCanary: | mStartedActivity = false
D/LeakCanary: | mStopped = true
D/LeakCanary: | mTemporaryPause = false
D/LeakCanary: | mTitle = java.lang.String@314691776 (0x12c1d0c0)
D/LeakCanary: | mTitleColor = 0
D/LeakCanary: | mTitleReady = true
D/LeakCanary: | mToken = android.os.BinderProxy@323829824 (0x134d4040)
D/LeakCanary: | mTranslucentCallback = null
D/LeakCanary: | mUiThread = java.lang.Thread@1955762776 (0x74929258)
D/LeakCanary: | mVisibleBehind = false
D/LeakCanary: | mVisibleFromClient = true
D/LeakCanary: | mVisibleFromServer = true
D/LeakCanary: | mVoiceInteractor = null
D/LeakCanary: | mWindow = com.android.internal.policy.PhoneWindow@317655136 (0x12ef0860)
D/LeakCanary: | mWindowAdded = true
D/LeakCanary: | mWindowManager = android.view.WindowManagerImpl@323839680 (0x134d66c0)
D/LeakCanary: | mInflater = com.android.internal.policy.PhoneLayoutInflater@323776416 (0x134c6fa0)
D/LeakCanary: | mOverrideConfiguration = null
D/LeakCanary: | mResources = android.content.res.Resources@315044736 (0x12c73380)
D/LeakCanary: | mTheme = android.content.res.Resources$Theme@323839712 (0x134d66e0)
D/LeakCanary: | mThemeResource = 2131427393
D/LeakCanary: | mBase = android.app.ContextImpl@319796480 (0x130fb500)
D/LeakCanary: | shadow$_klass_ = com.me.ui.playback.PlaybackFullscreenActivity
D/LeakCanary: | shadow$_monitor_ = 1293121552
D/LeakCanary: * Excluded Refs:
D/LeakCanary: | Field: android.view.inputmethod.InputMethodManager.mNextServedView
D/LeakCanary: | Field: android.view.inputmethod.InputMethodManager.mServedView
D/LeakCanary: | Field: android.view.inputmethod.InputMethodManager.mServedInputConnection
D/LeakCanary: | Field: android.view.inputmethod.InputMethodManager.mCurRootView
D/LeakCanary: | Field: android.os.UserManager.mContext
D/LeakCanary: | Field: android.net.ConnectivityManager.sInstance
D/LeakCanary: | Field: android.view.Choreographer$FrameDisplayEventReceiver.mMessageQueue (always)
D/LeakCanary: | Thread:FinalizerWatchdogDaemon (always)
D/LeakCanary: | Thread:main (always)
D/LeakCanary: | Thread:LeakCanary-Heap-Dump (always)
D/LeakCanary: | Class:java.lang.ref.WeakReference (always)
D/LeakCanary: | Class:java.lang.ref.SoftReference (always)
D/LeakCanary: | Class:java.lang.ref.PhantomReference (always)
D/LeakCanary: | Class:java.lang.ref.Finalizer (always)
D/LeakCanary: | Class:java.lang.ref.FinalizerReference (always)
谁能帮帮我?
提前致谢。
最佳答案
此漏洞已修复并在 25.2.0 支持库中发布。字体:issuetracker
关于java - MediaControllerCompat 内存泄漏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41396814/
我正在编写一个具有以下签名的 Java 方法。 void Logger(Method method, Object[] args); 如果一个方法(例如 ABC() )调用此方法 Logger,它应该
我是 Java 新手。 我的问题是我的 Java 程序找不到我试图用作的图像文件一个 JButton。 (目前这段代码什么也没做,因为我只是得到了想要的外观第一的)。这是我的主课 代码: packag
好的,今天我在接受采访,我已经编写 Java 代码多年了。采访中说“Java 垃圾收集是一个棘手的问题,我有几个 friend 一直在努力弄清楚。你在这方面做得怎么样?”。她是想骗我吗?还是我的一生都
我的 friend 给了我一个谜语让我解开。它是这样的: There are 100 people. Each one of them, in his turn, does the following
如果我将使用 Java 5 代码的应用程序编译成字节码,生成的 .class 文件是否能够在 Java 1.4 下运行? 如果后者可以工作并且我正在尝试在我的 Java 1.4 应用程序中使用 Jav
有关于why Java doesn't support unsigned types的问题以及一些关于处理无符号类型的问题。我做了一些搜索,似乎 Scala 也不支持无符号数据类型。限制是Java和S
我只是想知道在一个 java 版本中生成的字节码是否可以在其他 java 版本上运行 最佳答案 通常,字节码无需修改即可在 较新 版本的 Java 上运行。它不会在旧版本上运行,除非您使用特殊参数 (
我有一个关于在命令提示符下执行 java 程序的基本问题。 在某些机器上我们需要指定 -cp 。 (类路径)同时执行java程序 (test为java文件名与.class文件存在于同一目录下) jav
我已经阅读 StackOverflow 有一段时间了,现在我才鼓起勇气提出问题。我今年 20 岁,目前在我的家乡(罗马尼亚克卢日-纳波卡)就读 IT 大学。足以介绍:D。 基本上,我有一家提供簿记应用
我有 public JSONObject parseXML(String xml) { JSONObject jsonObject = XML.toJSONObject(xml); r
我已经在 Java 中实现了带有动态类型的简单解释语言。不幸的是我遇到了以下问题。测试时如下代码: def main() { def ks = Map[[1, 2]].keySet()
一直提示输入 1 到 10 的数字 - 结果应将 st、rd、th 和 nd 添加到数字中。编写一个程序,提示用户输入 1 到 10 之间的任意整数,然后以序数形式显示该整数并附加后缀。 public
我有这个 DownloadFile.java 并按预期下载该文件: import java.io.*; import java.net.URL; public class DownloadFile {
我想在 GUI 上添加延迟。我放置了 2 个 for 循环,然后重新绘制了一个标签,但这 2 个 for 循环一个接一个地执行,并且标签被重新绘制到最后一个。 我能做什么? for(int i=0;
我正在对对象 Student 的列表项进行一些测试,但是我更喜欢在 java 类对象中创建硬编码列表,然后从那里提取数据,而不是连接到数据库并在结果集中选择记录。然而,自从我这样做以来已经很长时间了,
我知道对象创建分为三个部分: 声明 实例化 初始化 classA{} classB extends classA{} classA obj = new classB(1,1); 实例化 它必须使用
我有兴趣使用 GPRS 构建车辆跟踪系统。但是,我有一些问题要问以前做过此操作的人: GPRS 是最好的技术吗?人们意识到任何问题吗? 我计划使用 Java/Java EE - 有更好的技术吗? 如果
我可以通过递归方法反转数组,例如:数组={1,2,3,4,5} 数组结果={5,4,3,2,1}但我的结果是相同的数组,我不知道为什么,请帮助我。 public class Recursion { p
有这样的标准方式吗? 包括 Java源代码-测试代码- Ant 或 Maven联合单元持续集成(可能是巡航控制)ClearCase 版本控制工具部署到应用服务器 最后我希望有一个自动构建和集成环境。
我什至不知道这是否可能,我非常怀疑它是否可能,但如果可以,您能告诉我怎么做吗?我只是想知道如何从打印机打印一些文本。 有什么想法吗? 最佳答案 这里有更简单的事情。 import javax.swin
我是一名优秀的程序员,十分优秀!