how to search Memory leak

tarou chabi 731 Reputation points
2022-05-01T07:38:27.127+00:00

When I forgot close filereader etc. with windows10 , how to check "close forget"?
When I forgot close serversocket with windows server 2016 or rhel8, how to check "close forget"?

I trid to open a file by java filereader and I quit the program without closing filereader.
And I checked the resource moniter.
But I couldn't find the "close forget" process. I can't close the "close forget" by OS.

Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
11,818 questions
Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
13,353 questions
{count} votes

2 answers

Sort by: Most helpful
  1. MotoX80 34,686 Reputation points
    2022-05-03T13:47:01.357+00:00

    I'm sorry but the phrase "many close forgot process" just doesn't make any sense.

    When I forgot close filereader etc. with windows10 , how to check "close forget"?

    If you run a program that opens a file, when that process terminates, the file is closed because the process memory is released. If the process is still running, and in your code you forgot to close the file, then that is a programming bug that you need to fix.

    Here is a VB script that opens a file and then displays a message box. Using Process Explorer we can use the Find menu to search for an open handle. It finds that cscript.exe has the file open. Note that the script does not issue a file close. When I click on "Ok", the cscript process terminates. Refreshing the Process Explorer search no longer finds the open file. That is because the process has terminated. A reboot will have the same results.

    198561-capture.png

    You can also set the lower pane view to display handles. Then select a process to view all open handles.

    198562-capture1.png

    For the StackOverflow post, there are answers posted to that question. If you need further help with that, then post a reply on that site.

    If you need help with the Java BufferedReader object, then you need to ask a question in a Java development forum.


  2. MotoX80 34,686 Reputation points
    2022-05-04T16:24:01.773+00:00

    If there is no file open, then what is the problem that you are having?

    You are not finding it because Java.exe has terminated. Look at the second image that I posted. Cmd.exe is the parent process and it has 2 child processes, conhost.exe and cscript.exe. Conhost just manages the console window. Cscript.exe is what is executing my FileTests.vbs script. That is the process that has the file open.

    Look at the second image that you posted. You have highlighted conhost.exe, but no user code runs in that process. There should be another child process (java.exe?) that processes your code (some .jar file?).

    You need to add a line of code to prompt the user to enter something.

    https://www.geeksforgeeks.org/console-readline-method-in-java-with-examples/

    That will leave java.exe running and waiting for input from you. Then switch over to ProcExp and search for the file. You should see java.exe running just like cscript.exe is running for me.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.