Skip to content

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

@rococode

Description

@rococode

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions