The bundled TeamSpeak 3 plugin gamepad_joystick_win64.dll (“Gamepad and Joystick Hotkey Support” 1.2, TeamSpeak Systems GmbH) opens every HID device on the system with CreateFileA, reads its attributes with HidD_GetAttributes, and never closes the handle. The DLL does not call CloseHandle anywhere.
Each enumeration leaks one handle per HID collection, and the handles stay open until ts3client_win64.exe exits. On my machine the client held 2,048 of them a few minutes after startup and about 329,000 after four days.
Windows’ HID class driver (HIDCLASS.SYS) copies every input report to every open handle on the device. With around 10,000 handles per device, each mouse, keyboard or headset report turns into about 10,000 kernel pool allocations inside the USB controller’s DPC. I measured DPCs of up to 127 ms on CPU 0. Audio drops out (the Windows audio engine logs KSENDPOINT…NO_OUTSTANDING_PACKETS glitches) and the mouse lags across the whole system. It gets worse the longer the client runs and goes away when TeamSpeak is restarted.
This looks like the cause of the existing community report “Lags/Latency due to TeamSpeak”, where DPC latency rises the longer TeamSpeak runs and only a client restart fixes it. Nobody in that thread found the cause.
Environment
| Item | Value |
|---|---|
| OS | Windows 11 Enterprise 25H2, build 26200.9711, x64 |
| TeamSpeak | ts3client_win64.exe 3.6.2.0 (C:\Program Files\TeamSpeak 3 Client) |
| Plugin | %APPDATA%\TS3Client\plugins\gamepad_joystick_win64.dll |
| Plugin identity (from its exports) | name “Gamepad and Joystick Hotkey Support”, version “1.2”, author “TeamSpeak Systems GmbH”, plugin API 26 |
| Plugin file | 152,064 bytes, PE timestamp 2023-06-20 08:54:22 UTC, not Authenticode-signed |
| Plugin SHA-256 | E3953EF6742AAD113985848A6473F329E3A5C5C800E0A40332D7AD7A7B7CB934 |
| CPU / USB | AMD Ryzen 7 9800X3D, AMD xHCI controllers (USBXHCI.SYS) |
| HID devices | Razer Viper V2 Pro mouse, USB keyboard (258A:0049), HyperX Cloud III Wireless headset, pen display (HID\PENTABLET), ASUS AURA and ASUS USB audio HID, spacedesk virtual HID |
| Other loaded modules | No other module in the client process imports any HID or SetupAPI function. gamepad_joystick_win64.dll is the only one. |
Symptoms
Music and other audio stutter or freeze for a moment, and the mouse lags at the same time. It comes in bursts, gets worse the longer TeamSpeak runs, and stops after a client restart.
Evidence 1: handle counts in a long-running client
The client started on 2026-11-17 at 13:22:37. I measured it on 2026-11-21 at about 18:31, roughly 4 days and 5 hours later.
It held 330,075 handles. The next-highest process on the system had 11,904. Of those handles, 328,874 were File handles with granted access 0x00100080 (SYNCHRONIZE | FILE_READ_ATTRIBUTES), which is what CreateFile(path, dwDesiredAccess = 0, …) returns. 328,872 of them pointed at \Device\<PDO> objects of HID collections. I listed them with Sysinternals handle64 -a -p <pid> and mapped each PDO name to its device with DEVPKEY_Device_PDOName.
| Device (HID collection) | Open handles held by ts3client |
|---|---|
HyperX Cloud III Wireless, 3 collections (HID\VID_03F0&PID_05B7&MI_03&COL01..03) |
11,664 each |
Pen display, 5 collections (HID\PENTABLET&COL01..05) |
11,664 each |
ASUS AURA (HID\VID_0B05&PID_19AF&MI_02), ASUS USB audio HID (HID\VID_0B05&PID_1A52&MI_07) |
11,664 each |
Razer Viper V2 Pro, 10 collections (HID\VID_1532&PID_00A6…) |
10,462 each |
| Keyboard 258A:0049, 9 collections | 5,583 each |
| spacedesk virtual keyboard / pen / touch | 624 / 384 / 384 |
| Device instances already removed from the system (unnamed PDOs, still held open) | 31 to 944 each, about 150 PDOs |
Every collection that was present for the whole session has the same count, 11,664, and devices that showed up later have proportionally fewer. The client ran a full “open every HID device” pass 11,664 times and closed none of the handles.
Evidence 2: a freshly started client leaks right away
On the same machine I restarted the client at 18:39:04. At 18:44:05 each of the 32 HID collections on the system had exactly 64 open handles from ts3client, 2,048 in total, all with access 0x00100080. At 18:45:37, after sitting idle, the count was still 2,048.
64 handles per collection means 64 full enumerations during startup, which fits one enumeration per raw-input device on its first lookup (see Evidence 3). The startup leak alone grows with the number of HID collections times the number of raw-input devices.
Evidence 3: static analysis of gamepad_joystick_win64.dll (1.2, SHA-256 above)
I disassembled the DLL with capstone and took function boundaries from .pdata. The image base is 0x180000000, and the addresses below are virtual addresses.
The HID enumeration routine is sub_1800039F0. It calls HidD_GetHidGuid, SetupDiGetClassDevsA, SetupDiEnumDeviceInfo and SetupDiGetDeviceInstanceIdA, then SetupDiEnumDeviceInterfaces and SetupDiGetDeviceInterfaceDetailA (twice), then CreateFileA (0x180005A67) and HidD_GetAttributes (0x180005A8D). It loops back through SetupDiEnumDeviceInterfaces (0x180005BB7) and ends with SetupDiDestroyDeviceInfoList (0x180005C31).
The handle from CreateFileA goes straight into HidD_GetAttributes and is then dropped:
180005a47: mov qword ptr [rsp+0x30], r14 ; hTemplateFile = NULL
180005a4c: mov dword ptr [rsp+0x28], r14d ; dwFlagsAndAttributes = 0
180005a51: mov dword ptr [rsp+0x20], 3 ; dwCreationDisposition = OPEN_EXISTING
180005a59: xor r9d, r9d ; lpSecurityAttributes = NULL
180005a5c: xor edx, edx ; dwDesiredAccess = 0
180005a5e: lea r8d, [r9+3] ; dwShareMode = FILE_SHARE_READ|FILE_SHARE_WRITE
180005a62: mov rcx, qword ptr [rsp+0x70] ; lpFileName = device interface path
180005a67: call qword ptr [CreateFileA]
180005a6d: cmp rax, -1
180005a71: je 0x180005b26
180005a77: mov dword ptr [rsp+0xd8], 0xc ; HIDD_ATTRIBUTES.Size = 12
180005a82: lea rdx, [rsp+0xd8]
180005a8a: mov rcx, rax ; handle passed to HidD_GetAttributes ...
180005a8d: call qword ptr [HidD_GetAttributes]
180005a93: test al, al
180005a95: je 0x180005b26
... ; ... VID/PID compared/stored; rax (the handle) is never saved or closed
CloseHandle is in the import table, but nothing in .text calls it or references its import slot. The dwDesiredAccess = 0 in this call produces the 0x00100080 access mask that every leaked handle has.
The enumeration is reached from sub_180008CE0, a subclassed window procedure. It ends in CallWindowProcA, has no direct callers, and handles two messages:
WM_INPUT(0xFF):GetRawInputData, a check forRAWINPUTHEADER.dwType == RIM_TYPEHID(cmp dword ptr [r15], 2),GetRawInputDeviceInfoA(RIDI_DEVICEINFO), thensub_180007E40.WM_DEVICECHANGE(0x219):sub_180008320, which callsGetRawInputDeviceListandGetRawInputDeviceInfoAand thensub_180007E40for each device.
sub_180007E40 gets the device name with GetRawInputDeviceInfoW(RIDI_DEVICENAME), upper-cases it and calls sub_1800076F0. That function locks a mutex and looks the device up in a hash map (sub_180011340, then cmp qword ptr [rax+8], 0). On a miss (je 0x1800079CA) it calls sub_1800039F0, so each cache miss from either message leaks one handle for every HID collection on the system.
Evidence 4: kernel traces linking the handles to the stalls
I recorded these with xperf from the Windows Performance Toolkit (kernel flags DPC+INTERRUPT+PROFILE, -stackwalk Profile) on the long-running client while the stutter was happening, and resolved symbols from the Microsoft public symbol server.
Trace A covers 63 seconds and ends right after an audible dropout. It has 1,527 DPCs of 1 ms or longer, all attributed to Wdf01000.sys. The longest was 126.7 ms, and 7 fell between 65 and 131 ms. The rest: 418 between 1 and 2 ms, 411 between 2 and 4 ms, 525 between 4 and 8 ms, 98 between 8 and 16 ms, and 42 between 16 and 32 ms. Microsoft-Windows-Audio logged op_EVT_GLITCH_KSENDPOINT_IOMGR_NO_OUTSTANDING_PACKETS at t = 58.55 s and 58.63 s and …BASE_END_GLITCH at 58.57 s, during a run of DPCs of 16 ms or longer between 58.5 and 58.8 s.
Trace B covers 91 seconds and ends right after audio and mouse lag. It has 507 DPCs of 4 ms or longer, all on CPU 0, the longest 106.8 ms. Of the 4,113 CPU profile samples that landed inside those DPCs, 3,624 have this stack, and the rest are variants of it:
ntoskrnl!ExFreePoolWithTag / ExAllocateHeapPool / ExAllocatePool2 / KeAcquireSpinLockRaiseToDpc / KeReleaseSpinLock
< HIDCLASS!HidpProcessInterruptReport
< HIDCLASS!HidpDistributeInterruptReport
< HIDCLASS!HidpInterruptReadComplete
< ntoskrnl!IopfCompleteRequest
< USBXHCI!Bulk_Transfer_CompleteCancelable
< USBXHCI!Bulk_ProcessTransferEventWithED1
< USBXHCI!TR_TransferEventHandler
< USBXHCI!Endpoint_TransferEventHandler
< USBXHCI!UsbDevice_TransferEventHandler
< USBXHCI!Interrupter_DeferredWorkProcessor
< USBXHCI!Interrupter_WdfEvtInterruptDpc
Functions at the sampled instruction pointer inside those DPCs:
| Samples | Function |
|---|---|
| 763 | nt!ExAllocateHeapPool |
| 552 + 300 | nt!ExFreePoolWithTag |
| 422 | nt!KeAcquireSpinLockRaiseToDpc |
| 395 | nt!ExAllocatePool2 |
| 338 + 142 | nt!KeReleaseSpinLock |
HidpDistributeInterruptReport delivers each input report to every open file object (handle) on the collection and allocates for each one. With about 10,000 leaked handles per collection, one USB HID input report costs about 10,000 allocate, free and lock round trips at DISPATCH_LEVEL inside the xHCI DPC. While that runs, USB audio and the audio engine get no buffers, and mouse input on CPU 0 waits.
Steps to reproduce
- Use Windows 10 or 11 with TeamSpeak 3.6.2 and the bundled “Gamepad and Joystick Hotkey Support” plugin enabled (it is on by default). Connect a few USB HID devices, such as a mouse, keyboard and headset.
- Start
ts3client_win64.exe. - As administrator, run
handle64.exe -a -p <ts3 pid>(Sysinternals) and count lines likeFile (---) \Device\000000xxwhere\Device\000000xxis a HID collection PDO.- Expected: none, or one per device if the plugin keeps devices open on purpose.
- Actual: N × M handles. On my machine every HID collection was open 64 times right after startup (2,048 in total), and the count kept growing with normal use, to about 329,000 after four days.
- Leave the client running for a day or more with normal mouse, keyboard and headset use, plus some device plugging and unplugging or sleep and wake. DPC latency (LatencyMon or
xperf -a dpcisr) keeps rising, audio crackles and the mouse lags. Restarting the client fixes it. - Disable the plugin in Tools > Options > Addons > Plugins > “Gamepad and Joystick Hotkey Support” and restart TeamSpeak. The leaked
\Device\…handles are gone.
Not yet determined
I don’t know which runtime event drives the slow growth after startup. The code shows two paths into the leak, WM_INPUT with RIM_TYPEHID and WM_DEVICECHANGE, both through a cache miss in sub_1800076F0. On a fresh client, a software re-plug of an already known device (pnputil /restart-device) added no handles. Neither did a synthetic WM_DEVICECHANGE / DBT_DEVNODES_CHANGED sent to the client’s top-level windows. So the growth comes from cache misses I couldn’t trigger on demand. Over four days on my machine it averaged one full enumeration about every 31 seconds. This doesn’t change the fix, since every enumeration leaks.
Suggested fix
In the enumeration routine (sub_1800039F0), close the handle after reading the attributes, on both the success and the failure path:
HANDLE h = CreateFileA(detail->DevicePath, 0, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, 0, NULL);
if (h != INVALID_HANDLE_VALUE) {
HIDD_ATTRIBUTES attr = { sizeof(attr) };
BOOL ok = HidD_GetAttributes(h, &attr);
CloseHandle(h); // <-- missing
if (ok) { /* use attr.VendorID / attr.ProductID */ }
}
The plugin would also do less work if it cached the device-to-VID/PID mapping so a miss doesn’t reopen every HID device, and if it enumerated only on DBT_DEVICEARRIVAL and DBT_DEVICEREMOVECOMPLETE. The VID and PID are also available from the raw-input device info (RIDI_DEVICEINFO, RID_DEVICE_INFO_HID.dwVendorId / dwProductId), which needs no CreateFile call at all.
Workaround for users
If you don’t use a gamepad or joystick for hotkeys, disable “Gamepad and Joystick Hotkey Support” in Tools > Options > Addons > Plugins and restart TeamSpeak. If you need it, restart the client now and then; disconnecting from the server isn’t enough, the process has to exit.
To check whether you’re affected, run (Get-Process ts3client_win64).HandleCount in PowerShell. A healthy client stays in the low thousands. The affected client reached 330,075.