克服 Windows 用户对象句柄限制 [英] Overcoming Windows User Object Handle Limit

查看:25
本文介绍了克服 Windows 用户对象句柄限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找在构建重量级 Windows 界面时处理用户对象句柄限制的高级策略.请解释您如何使用 SWT 或直接 Windows GUI API 克服或绕过此问题.我唯一不感兴趣的是优化小部件使用的策略,因为我已经广泛地这样做了,但它并没有解决问题,只会降低它的可能性.

I'm looking for advanced strategies for dealing with User Object Handle limits when building heavy-weight windows interfaces. Please explain how you overcame or bypassed this issue using SWT or direct Windows GUI APIs. The only thing I am not interested in is strategies to optimize widget usage as I have done this extensively and it does not solve the problem, only makes it less likely.

我的情况:
我有一个基于 SWT 的 GUI,它允许在同一个父 shell 中进行多个会话,并且在每个会话中,它们有 3 个单独的位置,其中显示用户生成的评论列表.当用户打开多个会话并提取填充这些列表的数据时,用户对象句柄的数量可能会根据评论数量急剧增加.

My Situation:
I have an SWT based GUI that allows for multiple sessions within the same parent shell and within each session their are 3 separate places where a list of user generated comments are displayed. As a user opens multiple sessions and pulls data that populates those lists, the number of user object handles can increase dramatically depending on the number of comments.

我目前的解决方案:
1. 默认情况下,我对评论进行分页,从而限制了每个会话中的评论行数,但由于管理需要,我还有一个有效的查看全部"按钮,完全绕过了这一点.
2.我自定义绘制每一行中所有不可编辑的信息.这意味着每行仅使用 2 个对象句柄.
3. 我创建了 JNI 调用,用于查询操作系统的当前使用量和最大使用量.有了这个,我可以向用户发出即将发生崩溃的迹象.不用说,他们忽略了这个警告.

My current solutions:
1. I page the comments by default thereby limiting the number of comment rows in each session, but due to management demands, i also have what is effectively a "View All" button which bypasses this completely.
2. I custom draw all non-editable information in each row. This means each row utilizes only 2 object handles.
3. I created JNI calls which query the OS for the current usage and the Max usage. With this i can give indications to users that a crash is imminent. Needless to say, they ignore this warning.

推荐答案

首先,您确定问题不是桌面堆与句柄计数吗?每个句柄可以消耗一定数量的 Windows 桌面堆.一个 USER 句柄可能占用大量空间,有些占用空间很小.我建议这样做是为了确保当它真的是别的东西时你不会追逐用户句柄计数.(google for Microsoft 的 dheapmon 工具,可能有帮助)

First off, are you sure the problem isn't desktop heap vs. handle count? Each handle can consume a certain amount of Windows desktop heap. One USER handle may eat a lot of space, some very little. I'm suggesting this to make sure you're not chasing user handle counts when it's really something else. (google for Microsoft's dheapmon tool, it may help)

我读到您可以通过更改注册表中的键来更改句柄的最大值:

I've read that you can alter the maxes on handles by changing keys in the registry:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows\ USERProcessHandleQuotaGDIProcessHandleQuota

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\ CurrentVersion\Windows\ USERProcessHandleQuota and GDIProcessHandleQuota

这对用户来说可能是一个短期修复.

This could be a short term fix for users.

我会首先弄清楚每个项目需要维护哪些 2 个用户句柄(例如列表框中的每个项目 2 个?).这似乎很可疑.用户句柄仅用于少数顶级 Windows UI 对象(窗口、菜单、光标、窗口位置、图标 等...).我不明白为什么您的小部件需要为每个项目保留 2 个对象(它是图标句柄吗??).

I'd approach this by first figuring out what 2 user handles need to be maintained for each item (like 2 for each item in a listbox?). This seems suspect. User handles are for only a few top-level Windows UI objects (Windows, menus, cursors, Window positions, icons, etc...). I don't see why your widget needs to keep 2 objects around for each item (is it an icon handle??).

如果你想把整个事情拆开 - 这听起来像是 虚拟模式列表视图 (LVS_OWNERDATA).

If you're looking to rip the whole thing apart - this sounds like a job for a virtual-mode List-View (LVS_OWNERDATA).

这篇关于克服 Windows 用户对象句柄限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆