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

Fix handle leak in Windows for Java >= 10 #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

effad
Copy link

@effad effad commented Feb 18, 2020

As discussed in profesorfalken/jProcesses#32, there is a handle leak when using WM4Java for Java versions beyond 10.
This PR works around the problem by explicetly closing the streams of process.

Here's a Test that can be executed to demonstrate the problem:

    public void testWindowsHandleLeak() {
    	JProcesses jprocesses = JProcesses.get().fastMode();
    	for (int i = 0; i < 1000; i++) {
    		jprocesses.listProcesses();
    		System.gc();
    		System.out.println("#" + i);
    	}    	
    }

when run one can see in the task manager that the handles of the javaw executable go up all the time.
After the fix is applied, handle count stays stable.

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

Successfully merging this pull request may close these issues.

1 participant