windows SWT 不再有手柄

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2018553/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 07:01:33  来源:igfitidea点击:

SWT No More Handles

windowsswthandles

提问by James

Windows XP has the limit 10000 user handles for each process and total 32000 for each desktop session. However, when I run 4 or 5 SWT process, each consuming no more than 2000 user handles, the SWT No More handles exception will always be threw.

Windows XP 对每个进程有 10000 个用户句柄的限制,每个桌面会话总共有 32000 个用户句柄。但是,当我运行 4 或 5 个 SWT 进程时,每个进程消耗不超过 2000 个用户句柄,将始终抛出 SWT No More handles 异常。

Does anyone know why?

有谁知道为什么?

回答by Paul Lammertsma

If I understand you correctly, you are probably getting the following exception:

如果我理解正确,您可能会遇到以下异常:

org.eclipse.swt.SWTError: No more handles

You may be creating resources (such as Font, Imageor GCobjects) that you aren't correctly disposing. You might want to take a moment to read through the SWT guide on Managing Operating System Resources.

您可能正在创建未正确处置的资源(例如FontImageGC对象)。您可能需要花点时间阅读有关管理操作系统资源的 SWT 指南。

To determine if this is indeed the case, I can recommend this useful article: Diagnosing Handle Leaks in SWT/RCP Windows Applications, which explains what resources are and suggests using Process Exploreror DPusto locate leaks.

为了确定是否确实如此,我可以推荐这篇有用的文章:诊断 SWT/RCP Windows 应用程序中的处理泄漏,它解释了资源是什么,并建议使用进程资源管理器DPus来定位泄漏。

A colleague also highly recommends Sleak, a SWT-focused application that can actually inform you which resources are remaining in residual memory.

一位同事还强烈推荐Sleak,这是一个专注于 SWT 的应用程序,它实际上可以通知您剩余内存中剩余哪些资源。

For a very technical understanding of what handles SWT is making, this Sybase article describesthat there are three kinds: User Object, GDI Object or Kernel Object handles, each of which has its own maximum.

对于 SWT 正在制作的句柄的技术性理解,这篇 Sybase 文章描述了三种类型:用户对象、GDI 对象或内核对象句柄,每种句柄都有自己的最大值。

回答by fisherja

You have some sort of resource leak in your program most likely. Use the following utility (http://www.eclipse.org/articles/swt-design-2/sleak.htm) as an easy way to find swt resource leaks. I used it to clean up a whole slew of problems in an rcp app I was working on

您的程序中很可能存在某种资源泄漏。使用以下实用程序 ( http://www.eclipse.org/articles/swt-design-2/sleak.htm) 作为查找 swt 资源泄漏的简单方法。我用它来清理我正在处理的 rcp 应用程序中的一大堆问题

回答by ReinstateMonica Larry Osterman

The limit isn't 10000 handles. Applications can use far more than 10000 handles (if RAM allows). The limit is on GDI and User resources (graphical elements).

限制不是 10000 个句柄。应用程序可以使用远远超过 10000 个句柄(如果 RAM 允许)。限制是 GDI 和用户资源(图形元素)。

What kind of resources are the SWT applications using (you can see this with taskmgr)? That would help to understand what is leaking.

SWT 应用程序使用什么类型的资源(您可以通过 taskmgr 看到这一点)?这将有助于了解泄漏的内容。

回答by javamonkey79

For the record, if this were my question I would have accepted @Paul's answer. However, there is one sneaky issue that I'd like to add here to potentially help someone else if they come across this problem...

作为记录,如果这是我的问题,我会接受@Paul 的回答。但是,我想在这里添加一个偷偷摸摸的问题,以便在其他人遇到此问题时可能会有所帮助...

Check your usage of fonts.

检查您对字体的使用。

In my case, my handles were not all that high, but instead I was new'ing up font instances and handing them to the StyledText style. I had to instead declare the fonts I wanted to use once, class level. This fixed it for me.

就我而言,我的句柄并没有那么高,而是我新建了字体实例并将它们交给了 StyledText 样式。我不得不声明我想使用一次的字体,类级别。这为我修好了。

回答by Adam

I've seen this error too in eclipse 3.6 SR1, it turned out to be caused by hundreds of editor tabs being left open. Closing the tabs fixed the error.

我在 eclipse 3.6 SR1 中也看到过这个错误,结果证明它是由数百个编辑器选项卡保持打开状态引起的。关闭选项卡修复了错误。

回答by user3740344

Try following steps:

尝试以下步骤:

  • go to eclipse home directory (where you installed eclipse), then go to plugins folder
  • remove all the recently install plugins starting with com.google.*
  • try restarting your eclipse again, it may start working again (worked for me.)
  • try to install old plugins from google or just once that you need. (I am going to try this.)
  • 转到 eclipse 主目录(安装 eclipse 的位置),然后转到 plugins 文件夹
  • 删除所有最近安装的以 com.google.* 开头的插件
  • 尝试再次重新启动您的日食,它可能会再次开始工作(对我有用。)
  • 尝试从谷歌安装旧插件,或者只安装一次你需要的插件。(我要试试这个。)

回答by Harpreet Singh Bhullar

On my system Windows7 x64 I can reproduce it when TeamViewer 8 is running (www.teamviewer.com). When I stop TeamViewer, the bug disappears.

在我的系统 Windows7 x64 上,我可以在 TeamViewer 8 运行时重现它(www.teamviewer.com)。当我停止 TeamViewer 时,错误消失了。

you may look into : https://bugs.eclipse.org/bugs/show_bug.cgi?id=402983

你可以看看:https: //bugs.eclipse.org/bugs/show_bug.cgi?id=402983

Hope that helps.

希望有帮助。

回答by Ivan

I've also met this problem, but now i've solved it.

In my case, i'm running Win7 with SP1 and Spring Tool Suite 3.7.2 (Eclipse Mars 4.5.1) through Citrix XenApp. This error happens when i switch between Package Explorerand Java Editor.

My solution:
run services.msc in Win7, find "Tablet PC Input Service", stop it.

Hope this may help others.

我也遇到过这个问题,但现在我已经解决了。

就我而言,我通过 Citrix XenApp 运行带有 SP1 和 Spring Tool Suite 3.7.2(Eclipse Mars 4.5.1)的 Win7。当我在Package ExplorerJava Editor之间切换时会发生此错误。

我的解决办法:
在Win7下运行services.msc,找到“平板电脑输入服务”,停止。

希望这可以帮助其他人。