异常场景:
经常在应用中需要处理一些耗时的工作,诸如读取大文件、访问网络资源等。为了避免因程序假死而带来的糟糕用户体验,通常我们可以通过线程+Handler或者Android提供的AsyncTask来解决该问题,并一般以ProgressDialog等提示性控件来告知用户当前的程序进度。而标题中描述的异常则会常常出现在这样的场景中,并且往往掩盖了导致异常的真正的罪魁祸首。
问题原因:
从异常描述中,大致的意思是存在窗口句柄泄露,即未能及时销毁某个PhoneWindow。而这往往误导了我们,把过多的精力放在查找所谓的内存泄露上了。其实存在这么一种情况,即因我们在非主线程中的某些操作不当而产生了一个严重的异常,从而强制当前Activity被关闭。而在关闭的同时,却没能及时的调用dismiss来解除对ProgressDialog等的引用,从而系统抛出了标题中的错误,而掩盖了真正导致这个错误的异常信息。
解决方法之一:
本解决方法并不能真正的解决问题,但是在一定程度上可以将真正导致错误的异常信息显露出来。即重写Activity的onDestroy方法,在方法中调用dismiss来解除对ProgressDialog等的引用。
原文:http://www.cnblogs.com/royenhome/archive/2011/05/20/2051879.html
分享到:
相关推荐
按字面了解,Window Leaked大概就是说一个窗体泄漏了,也就是我们常说的内存泄漏,为什么窗体会泄漏呢? 产生原因: 我们知道Android的每一个Activity都有个WindowManager窗体管理器,同样,构建在某个Activity之上...
代码比较简单,但是步骤结合博客还是很详细的,可以看我的博客http://blog.csdn.net/superbiglw/article/details/53156177
"git p4" was not properly quoted to protect a caret and running a broken command on Windows, which has been corrected. * "git request-pull" learned to warn when the ref we ask them to pull from ...
18)..Fixed: Possible "Unit XYZ was compiled with a different version of ABC" when using packages 19)..Fixed: FastMM shared MM compatibility 20)..Fixed: Minor bugs in stack tracing (which usually ...
Jenkins安装过程,每个运维都需要的系统。应为几乎所有的团队都需要它。
Windows XP/2003 Server操作系统源代码泄露文档合集:XP_Leaked_Source_Documentation.7z
Double-click on a line in the call stack to jump to that file and line in the editor window. It's a very effective way to quickly diagnose, and fix, memory leaks in C/C++ applications. The main ...
If you attempt to access a reserved address that has not yet been committed (backed by memory or disk) you will cause an access violation. Committed Memory Committed pages are those pages that when ...
F2084 Internal Error SCR765.00 of 5 Closed11193 Inlined function affects working of the enclosing for loop0.00 of 5 Closed11184 [Fatal Error] F2084 Internal Error: ILLK26340.00 of 5 Closed11069 ...
windbg source code, extracted from windows leaked src code.
This memory leak detector was created as a free alternative to the built-in memory leak detector provided with Visual C++. Here are some of Visual Leak Detector's features, none of which exist in the...
This memory leak detector was created as a free alternative to the built-in memory leak detector provided with Visual C++. Here are some of Visual Leak Detector's features, none of which exist in the...
require ( "leaked-handles" ) ; 示例输出。 no of handles 1 timer handle (`setTimeout(any, 1000)`) timer handle leaked at one of: at Test.t (/home/raynos/uber/leaked-handles/test/leak-timer.js:10:...
- Added a disassembler window for redirected code - Added colour to all known imports (Thanks to Jeff Schering) - Added a hex viewer (built with the disassembler) - Fixed blink in RichEdit ...
"The source code to the infamous Zeus crimeware kit, which has been sold on underground forums for years, has been leaked and is now available for anyone to see if they know where to look. Security ...
Samsung Leaked Source Torrent
微硬源码种子,本人已经试用过,并且在做种中,推荐使用qBittorrent进行分享,大家一起来分享学习,如侵权请告知删除
linux.mirai 泄漏Linux.Mirai研究/ IoC开发目的源代码 上传用于研究目的,因此我们可以开发IoC等。 如果您想知道所有内容的设置方式等信息,请参见“ post.txt”(在中)以了解其泄漏的信息。...
MS-DOS 6.0 Source Code Leaked
slider示例回购安装npm i react-swift-slider用法import SwiftSlider from 'react-swift-slider' const data = [ { 'id' : '1' , 'src' : 'https://media.mfbproject.co.za/repos/2017_alfa-romeo_stelvio_leaked_02...