nefarius / HidHide

Gaming Input Peripherals Device Firewall for Windows.
https://docs.nefarius.at/projects/HidHide/
MIT License
939 stars 80 forks source link

HIDHide Watchdog taking up large amounts of RAM #126

Closed rhobiusvoid closed 1 year ago

rhobiusvoid commented 1 year ago

Bug description

The Watchdog service that ensures the configs are set properly between updates or system changes is taking huge proportions of RAM, upwards of 300MB.

Steps to reproduce

Actual result: Letting it run over time will just keep growing its RAM usage, likely as a result of some memory leak. Expected result: Should just stay reasonable.

Screenshots

Would've posted one if I hadn't terminated it. Sorry.

Machine info

CPU-Architecture: x64 Windows version: Windows 10 LTSC 21H2 Software/driver version(s): Latest one, part of security bulletin, legacinated

Any other helpful information

n/a

nefarius commented 1 year ago

Uh oh. Do you have a relative feeling how long it ran until you noticed? What was the amount, roughly?

Oh, a few hundred megs, yeah that is not normal indeed 😅 we're leaking somewhere.

rhobiusvoid commented 1 year ago

I actually saw it a few days ago, where it was 500MB in RAM, but I thought nothing of it and just simply terminated it. Did a few restarts from then till here cuz of drivers for some dumb camera that didn't end up working, and I decided to peek into task manager cuz something wasn't right with another program, and that's where I saw the Watchdog service at 300MB. I only booted up my PC just an hour ago so the memleak is likely fast. I've since disabled the service, since I've completely disabled Windows Update anyways, but I've re-enabled it for now and I'm just steadily watching it.

nefarius commented 1 year ago

Yeah I can reproduce it, something isn't get cleaned up properly:

image

I'll look into it. Curious, the service is not awfully complex, wonder what the culprit is.

rhobiusvoid commented 1 year ago

Well, good to see that it was at least reproducible, would've been a nightmare if it was my system that caused it.

nefarius commented 1 year ago

I'll check util::HasDeviceClassFilter this is the most likely culprit since we do not leak handles and this function does allocate strings.

rhobiusvoid commented 1 year ago

Gotcha. On my end, it's just steadily increasing in kilobytes every few seconds, similar to your reproduction of it. image

nefarius commented 1 year ago

Yeah the thread runs its checks every 5 seconds.

nefarius commented 1 year ago

I'll check util::HasDeviceClassFilter this is the most likely culprit since we do not leak handles and this function does allocate strings.

Interesting, that function is innocent, I removed it and ramped up the polling rate, still leaks:

image

rhobiusvoid commented 1 year ago

and it's leaking even faster

nefarius commented 1 year ago

and it's leaking even faster

Because I changed 5 seconds to 50 milliseconds 😉

nefarius commented 1 year ago

Yep, CheckServiceStatus is at fault. Now to figure out why.

nefarius commented 1 year ago

Found and fixed it! Thanks for reporting! Next release will contain the fixed version.

rhobiusvoid commented 1 year ago

nicely done, and good to hear!

nefarius commented 1 year ago

Looking good now:

image

nefarius commented 1 year ago

@rhobiusvoid could you test this new build pls before I make a release, thanks: HidHide_1.4.192_x64.exe.zip

rhobiusvoid commented 1 year ago

Left it running for a good half hour or so, but it only occasionally rises by like 4KB at a very slow rate. Likely just my system at this point and nothing major. image

Edit: It stays at 700KB, no rise or fall. Must've just initialized.