异常场景:
经常在应用中需要处理一些耗时的工作,诸如读取大文件、访问网络资源等。为了避免因程序假死而带来的糟糕用户体验,通常我们可以通过线程+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之上...
在Android开发中,服务(Service)是四大组件之一,主要用于在后台执行长时间运行的任务,而绑定服务(Bound Service)则是服务的一种特殊形式,它允许其他组件(如Activity或BroadcastReceiver)通过接口与服务进行交互...
"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安装过程,每个运维都需要的系统。应为几乎所有的团队都需要它。
Leaked memory: Memory unreferenced by your application that cannot be used again or freed (also detectable by using the Leaks instrument). Abandoned memory: Memory still referenced by your application...
was being taught C. has been taught D. had been taught 答案:C. has been taught * 过去完成时(had done) 过去完成时用于描述在过去某个时间点之前完成的动作。例如: * 例 3:Anne asked Tom ______ the...
C++三维程序
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 ...
然而,"XP_Leaked_Source_Documentation.7z"这个文件名暗示了一个备受关注的事件——Windows XP和2003 Server操作系统的源代码泄露。源代码是软件开发的核心,通常被视为公司的最高机密,因为它们揭示了软件的工作...
压缩包子文件的文件名称“Symantec__s_pcAnywhere_Leaked_Source_Code.7014253.TPB.torrent”明确指出,泄露的源代码是针对赛门铁克的PCAnywhere产品。PCAnywhere是一款历史悠久的远程控制软件,允许用户通过互联网...
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 ...
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 ...
Samsung Leaked Source Torrent