SWT 不再有句柄

发布于 2024-08-16 22:14:14 字数 154 浏览 10 评论 0原文

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

有谁知道为什么?

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.

Does anyone know why?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

爱人如己 2024-08-23 22:14:14

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

org.eclipse.swt.SWTError: No more handles

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

要确定情况是否确实如此,我可以推荐这篇有用的文章:诊断 SWT/RCP Windows 应用程序中的句柄泄漏,其中解释了资源是什么并建议使用 Process ExplorerDPus 来定位泄漏。

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

要从技术角度了解 SWT 的处理方式,这篇 Sybase 文章描述句柄分为三种:用户对象、GDI 对象或内核对象句柄,每种句柄都有自己的最大值。

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, Image or GC objects) that you aren't correctly disposing. You might want to take a moment to read through the SWT guide on Managing Operating System Resources.

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 Explorer or DPus to locate leaks.

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

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

笑饮青盏花 2024-08-23 22:14:14

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

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

莫多说 2024-08-23 22:14:14

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

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

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).

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

仅冇旳回忆 2024-08-23 22:14:14

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

检查您对字体的使用。

就我而言,我的句柄不是都那么高,但相反,我正在新建字体实例并将它们交给 StyledText 样式。我不得不声明我想使用一次的字体,类级别。这为我解决了这个问题。

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...

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.

雪花飘飘的天空 2024-08-23 22:14:14

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

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.

蛮可爱 2024-08-23 22:14:14

尝试以下步骤:

  • 转到 Eclipse 主目录(安装 Eclipse 的位置),然后转到插件文件夹,
  • 删除所有最近安装的以 com.google.* 开头的插件。
  • 尝试再次重新启动 Eclipse,它可能会再次开始工作(对我有用。 )
  • 尝试安装来自谷歌的旧插件或仅安装一次您需要的插件。 (我要尝试这个。)

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.)
我很OK 2024-08-23 22:14:14

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

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

希望有帮助。

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

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

Hope that helps.

要走干脆点 2024-08-23 22:14:14

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

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

我的解决方案:
在Win7中运行services.msc,找到“平板电脑输入服务”,将其停止。

希望这可以帮助其他人。

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 Explorer and Java Editor.

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

Hope this may help others.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文