SWT - 如何调试“不再有句柄”

发布于 2024-10-22 12:57:11 字数 238 浏览 3 评论 0原文

有时我会被“org.eclipse.swt.SWTError:没有更多句柄”所困扰。我已经知道像 GDIView 这样的工具来观察分配的句柄数量,但现在我想知道是否有更好的方法来做到这一点。

有可用的工具吗?也许在创建句柄时记录所有堆栈跟踪?其中显示两个调用点之间的新句柄?

问候, Daniel

PS:添加了 windows 标签,因为开发主要发生在 Windows 上,并且仅 Windows 工具就足够了。

from time to time I am haunted by the "org.eclipse.swt.SWTError: No more handles". I already know tools like GDIView, to watch the number of handles allocated, but now I wonder if there is a better way to do this.

Is there a tool available? Maybe one that logs all stacktraces when handles are created? And which shows the new handles between two invocation points?

Regards,
Daniel

PS: Added the windows tag because dev occures mostly on windows and a windows only tool would be good enough.

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

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

发布评论

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

评论(3

你没皮卡萌 2024-10-29 12:57:11

我发现了 Sleak,这是一个调试 SWT 资源的好工具!强烈推荐给有同样问题的每个人。甚至还显示图像资源的图像!

I found out about Sleak, a great tool to debug SWT resources! Highly recommended for everyone with the same problems. Even shows the images for image resources!

最后的乘客 2024-10-29 12:57:11

对我来说,问题只是 new Shell() 被调用得太频繁。将 shell 存储为静态成员并重用它会有所帮助。因此,在应用像 Sleak 这样的工具之前,其他人可能想要对“new Shell”进行全文搜索,并检查它们是否有相同的简单原因。

For me the issue was simply that new Shell() has been called too often. Storing the shell as static member and reusing it helped. Therefore, before applying a tool like Sleak, others might want to do a full text search for "new Shell" and check that they don't have the same simple cause.

风向决定发型 2024-10-29 12:57:11

Sleak 似乎非常过时,我没有让它工作。
最终这也会对某人有所帮助。在 ui 代码的早期添加以下代码:

Display.getCurrent().DEBUG = true;
Display.getCurrent().setTracking(true);

关闭/处置应用程序时的输出:

Summary: 930 Font(s), 50 Image(s)

还会输出一个包含堆栈跟踪的列表,其中包含分配资源的位置。

有关更多详细信息,请参阅设备类源代码: https://github.com/eclipse-platform/eclipse.platform.swt/blob/7479681ce2cd75b1adb10220d061d83e4f83e2cd/bundles/org.eclipse.swt/Eclipse %20SWT/cocoa/org/eclipse/swt/graphics/Device.java

Sleak seems to be very outdated and I did not get it working.
Eventually this will also help someone. Add the following code early in your ui code:

Display.getCurrent().DEBUG = true;
Display.getCurrent().setTracking(true);

Output on close/dispose of the application:

Summary: 930 Font(s), 50 Image(s)

Also a list with stacktraces is outputed with places where resources was allocated.

See Device class source code for further details: https://github.com/eclipse-platform/eclipse.platform.swt/blob/7479681ce2cd75b1adb10220d061d83e4f83e2cd/bundles/org.eclipse.swt/Eclipse%20SWT/cocoa/org/eclipse/swt/graphics/Device.java

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