- 浏览: 144328 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
EclipseEye:
fair_jm 写道不错 蛮详细的 谢谢分享
SWT/JFace专题 --- SWT中Display和多线程 -
fair_jm:
不错 蛮详细的 谢谢分享
SWT/JFace专题 --- SWT中Display和多线程
在RCP开发中如果牵涉到 Color,Image,Font,Cursor 等的过频的操作或者数据量比较大时 出现该异常的可能性就很大了。
由于这些类的对象 每new一个就要消耗掉一个handler ,如果没有及时的dispose,而系统分配的handler数量有限,于是出现了该错误。
============
解决办法就是用缓存,在java里面可以用Map集合的形式来处理,把用到了每一个对象分别放到对应的Map中,在不需要时,对其dispose同时clear Map集合。
==================
缓存文件结构大概如下:
由于这些类的对象 每new一个就要消耗掉一个handler ,如果没有及时的dispose,而系统分配的handler数量有限,于是出现了该错误。
============
解决办法就是用缓存,在java里面可以用Map集合的形式来处理,把用到了每一个对象分别放到对应的Map中,在不需要时,对其dispose同时clear Map集合。
==================
缓存文件结构大概如下:
public class CacheManager { // colorMap public static Map<RGB, Color> colorMap = new HashMap<RGB, Color>(); public static Color getColor(int systemColorID) { Display display = Display.getCurrent(); return display.getSystemColor(systemColorID); } public static Color getColor(int r, int g, int b) { return getColor(new RGB(r, g, b)); } public static Color getColor(RGB rgb) { Color color = colorMap.get(rgb); if (color == null) { Display display = Display.getCurrent(); color = new Color(display, rgb); colorMap.put(rgb, color); } return color; } public static void disposeColors() { for (Color color : colorMap.values()) { color.dispose(); } colorMap.clear(); } //----------------------------------------- // imageMap public static Map<String, Image> imageMap = new HashMap<String, Image>(); protected static Image getImage(InputStream stream) throws IOException { try { Display display = Display.getCurrent(); ImageData data = new ImageData(stream); if (data.transparentPixel > 0) { return new Image(display, data, data.getTransparencyMask()); } return new Image(display, data); } finally { stream.close(); } } public static Image getImage(String relativePathName) {//这个参数是对插件项目而言的,比如可以是:"icons/xxx.jpg"等 //将插件项目中的 文件相对路径转换成 绝对路径的转换过程 Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID); URL url = bundle.getResource(relativePathName); String fullPathString = null; try { fullPathString = FileLocator.toFileURL(url).toURI().toString(); } catch (Exception e1) { e1.printStackTrace(); } fullPathString = fullPathString.replaceFirst("file:/", ""); Image image = imageMap.get(fullPathString); if (image == null) { try { image = getImage(new FileInputStream(fullPathString.toString())); imageMap.put(fullPathString, image); } catch (Exception e) { e.printStackTrace(); } } return image; } public static void disposeImages() { // dispose loaded images for (Image image : imageMap.values()) { image.dispose(); } imageMap.clear(); } //----------------------------------------- //fontMap //... //----------------------------------------- //cursorsMap //.... //------------------------------------------ /** * Dispose All */ public static void dispose() { disposeColors(); disposeImages(); //... //... } }
发表评论
-
再说SWT中的滚动面板ScrolledComposite实现
2013-06-19 15:43 2262记得以前写过一篇关于滚动面板的文章 SWT中 Scrolle ... -
OSGi参考资料
2013-04-18 01:11 653基于 OSGi 的面向服务的组件编程 探索 OSGi 框架的组 ... -
CDT(编辑、调试)参考资料
2013-04-17 02:15 1077CDT编辑器 --------- 构建基于 CDT 的编辑器, ... -
Workspace Resource框架专题(3)处理工作空间资源更改事件
2013-04-17 01:44 13293 处理工作空间资源更改事件 工作空间API允许工具对它 ... -
Workspace Resource框架专题(2)workspace 框架API
2013-04-17 01:27 14262 工作空间API 本 ... -
Workspace Resource框架专题(1)Resource的概念
2013-04-17 01:12 13391 Resource的概念 如 ... -
如何恢复断点及Marker
2013-03-05 00:41 0如何恢复断点及Marker -
深入Workbench框架
2013-03-01 02:10 1637深入Workbench框架(结合UIPersistent) 1 ... -
Eclipse插件开发中的Action
2013-02-24 23:10 1963插入点用来定义菜单出 ... -
Eclipse开发中编辑器(Editors)和视图(View)总结
2013-02-24 22:58 28261.视图(Views) 视图( ... -
SWT/JFace专题 --- 对话框向导(Dialogs Wizards)
2013-02-24 22:42 2115对话框向导(Dialogs Wizar ... -
SWT/JFace专题 --- JFace
2013-02-24 22:37 1574JFace JFace是基于SWT的一套图形工具包,它没有为 ... -
SWT/JFace专题 --- SWT中Display和多线程
2013-02-24 15:25 3163Display 1.Display 的创建 一个SWT程序 ... -
SWT/JFace专题 --- SWT API 结构
2013-02-23 18:31 1044SWT API 结构 1.布局类(l ... -
Eclipse启动过程(源码级剖析)
2013-02-20 03:24 3361双击eclipse安装目录下的eclipse.exe运行后,会 ... -
SWT/JFace专题 --- SWT结构浅析
2013-02-23 17:02 985SWT技术是一套基于Java的 ... -
Eclipse平台体系结构
2013-02-21 23:56 17751.Eclipse平台体系结构 1 ... -
RCP平台架构
2013-02-23 14:11 1404RCP 富客户端通常是指具有独立用户界面的客户端程序。富客户 ... -
Ant构建脚本相关
2013-02-18 01:26 0Ant构建脚本相关 -
CDT源码架构研究
2013-02-18 01:24 0CDT源码架构研究
相关推荐
有时候会弹出一个方框,里面的内容是Unhandled event loop exception No more handles,当你点击OK的时候,又会出来一个方框,里面第一句话是 An SWT error has occurred,并且诱导你关闭eclipse,严重影响了我们对...
org.eclipse.swt.SWTError: No more handles [MOZILLA_FIVE_HOME=''] (java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons: no swt-mozilla-gtk-4335 in java.library.path no swt-mozilla-gtk ...
解决org.eclipse.swt.SWTError: No more handles [MOZILLA_FIVE_HOME=''] (java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons: no swt-mozilla-gtk-4335 in java.library.path
Oh.exe: Open Handles Oleview.exe: OLE/COM Object Viewer Pathman.exe: Path Manager,路径管理 Permcopy.exe: Share Permissions Copy,共享权限复制 Perms.exe: User File Permissions Tool,用户文件权限...
:white_check_mark: Configuration change: Handles configuration changes :white_check_mark: Material Design: Not a fully Material Design App, but I am trying my best. :white_check_mark: Some custom ...
检测节点中泄漏的任何句柄 例子 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-...
Contents About the Author...............................................................................................xix About the Technical Reviewer and Contributing Author.................xxi ...
Matab GUI 的源代码,经过这个源代码的使用就可以很好掌握Matlab GUI的编写。
- FIX: UIScrollView's movement restriction now makes sense (no more weird 'scale') - FIX: Draggable panels should no longer move on Play. - FIX: Improved performance by reducing GC allocations and ...
the kind of data it handles. Although the description of the functions is in C language, the library has a standard format and may be called from any language. There is no need to install this file ...
Fix: C/C++ parsing support for managed pointers and "handles". Fix: C# symbol resolution for property and indexer member types. Fix: Several VHDL parser fixes. Misc: Code signing certificate ...
filehandles软件包是一个Python库,它通过从目录,zip归档文件,tar归档文件,文件的URL地址等中删除用于打开文件的模板代码,从而简化了文件处理过程。已处理。 链接 filehandles @ filehandles @ 安装 该file...
- NEW: Created a new layout system...- FIX: Rotating a widget should no longer hide its side handles. - FIX: Mobile keyboard will now have the multi-line option. - FIX: Re-added support for packed fonts.
If no output parameter is specified, then an interactive GUI window will be displayed with a tree-view of all container components, their properties and callbacks. Syntax: [handles,levels,parentIds,...
handles.output = hObject; hPush = findall; hToggle = findall; hPan = findall; set; set; loadmark = 0; beginmark = 0; guidata; 复制代码 源码如下: getdata.rar 源码 同时分享该...
文章目录源代码报错原因解决 源代码 # 需求:再添加一个城市的温度变化 #导入工具 import matplotlib.pyplot as plt import random #创建画布 plt.figure(figsize=(20,8),dpi = 80) #绘制图像,画出安徽省宣城市泾县...
kettle-linux环境下部署kettle,执行kitchen.sh文件报错后安装 libwebkitgtk,提示没有可用软件包libwebkitgtk 详细流程:https://blog.csdn.net/m0_37618809/article/details/81015492#commentBox
handles.figure1, handles.slider2. This | structure is created at GUI startup using GUIHANDLES and stored in | the figure s application data using GUIDATA. A copy of the structure | is passed to ...
资源集合:http://www.battlehub.net/ unity2022.1.16 & 发布了一个webgl 版本测试,它是可以工作的
flex-object-handles flex中对象的移动 编译 放大 缩小的功能 早期的版本