samuelcampos / usbdrivedetector

A Java library to get a list of all usb storage devices connected to the computer.
MIT License
128 stars 46 forks source link

Leaks native memory under Windows #33

Open TX256 opened 4 years ago

TX256 commented 4 years ago

This library appears to leak native memory under Windows 10.

After a night of running USBDriveDetector, with a polling interval of 500ms, my Windows machine has ran totally out of memory. Heap of the Java application has not increased at all, so it must be native memory that exhausts the system.

feilimb commented 4 years ago

Do you have a test harness that can demonstrate the issue for reproduction purposes? Did you have zero, one or multiple USB storage devices connected overnight? Which version of the USBDriveDetector library were you using (custom self-build, or one of the releases from the project page) ?

TX256 commented 4 years ago

Well, I don't have a test, but all I did was create an instance of USBDeviceDetectorManager, set polling interval to 500ms, and add one listener to it. I had zero USB storage devices plugged in during the time it leaked memory (and the computer was idle), so the listener was never even called.

I'm still using the library under Ubuntu, and can confirm that the problem does not exist on Linux.

I am using the latest version 2.1.1.

feilimb commented 4 years ago

I tried to reproduce this by running a simple harness with one listener and a 100ms polling interval. I left the application running for 8 hours+ however I could not reproduce the issue and saw no issues with native memory usage.

I was using latest codebase, on a Windows 10 system.