Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Insufficient system resources" after many calls to WindowUtils.getAllWindows(true) #1042

Closed
rococode opened this issue Dec 6, 2018 · 4 comments

Comments

@rococode
Copy link

rococode commented Dec 6, 2018

This is for my project rensa, specifically this class: https://github.com/rococode/rensa/blob/master/src/main/java/com/tangleroad/rensa/utils/WindowTitleFetcher.java

The main thing that's happening there is that getProcessWindowTitle is called frequently (a couple times a second). That method makes a call to WindowUtils.getAllWindows(true);.

After a large number of calls - I haven't measured the exact time but the program runs for 20-30+ hours before this happens - I start getting a resource problem that prevents me from calling that method anymore. It seems that I'm hitting the limit for open (file?) handlers or something like that, but I don't see anywhere that I'm clearly leaking these "resources".

You can see in the same class a commented-out getProcessWindowTitle2, which does the same thing but before I knew WindowUtils.getAllWindows(true); existed. It also suffered from the same issue of getting the win32exception after running for several hours.

Am I just missing some call I should be making to free whatever's causing issues? Or is there some bug in JNA that's holding on to resources for too long?

@rococode rococode changed the title "Insufficient system resources" after *many* calls to WindowUtils.getAllWindows(true) "Insufficient system resources" after many calls to WindowUtils.getAllWindows(true) Dec 6, 2018
@matthiasblaesing
Copy link
Member

com.sun.jna.platform.WindowUtils.W32WindowUtils.getProcessFilePath(HWND) opens a process, but does not close the returned handle. Please see #1043 for the change. I attach a test build to this message - please see if that fixed the problem.

jna-5.2.0-SNAPSHOP.zip

@rococode
Copy link
Author

rococode commented Dec 6, 2018

Running it now, I'll give an update in a couple days if it hasn't had any issues. Thanks for the quick turnaround!

@rococode
Copy link
Author

@matthiasblaesing my program's been running for a little over 3 days now with no crash. Looks like the problem is fixed, thanks!

@matthiasblaesing
Copy link
Member

Merged the changeset - thank you for taking time to test. I pushed an updated snapshot build to the sonatype snapshot repository.

https://oss.sonatype.org/content/repositories/snapshots//net/java/dev/jna/jna/5.2.0-SNAPSHOT/
https://oss.sonatype.org/content/repositories/snapshots//net/java/dev/jna/jna-platform/5.2.0-SNAPSHOT/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants