question

tarouchabi-7271 avatar image
0 Votes"
tarouchabi-7271 asked tarouchabi-7271 commented

how to search Memory leak

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-serverwindows-10-general
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I can't close the "close forget" by OS.

I can't speak for other forum users, but I do not understand what you mean by the phrase "close forget".

The Process Monitor utility can display file handles that processes have open. Is that what you are looking for?

https://docs.microsoft.com/en-us/sysinternals/downloads/process-explorer








0 Votes 0 ·

Thank for your replay.
This question is the same. I want to know if it can be confirmed in the OS boot process about "many close forgot process".
https://stackoverflow.com/questions/981196/how-to-know-if-a-bufferedreader-stream-is-closed

0 Votes 0 ·
MotoX80 avatar image
0 Votes"
MotoX80 answered MotoX80 converted comment to answer

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.



capture.png (138.8 KiB)
capture1.png (61.1 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Really, thank you very mcuh.y mcuh.
Yes. I want to search the bug. Now, I ran a simple code that forgot to close with dos.
And, I serach the text file. But, I can't hit. Is it a jvm problem....................

198741-image.png
198684-image.png
198697-image.png


0 Votes 0 ·
image.png (18.0 KiB)
image.png (8.7 KiB)
image.png (55.5 KiB)
MotoX80 avatar image
0 Votes"
MotoX80 answered tarouchabi-7271 commented

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.






· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks alot. When I finished java.exe, I understood that I can't find the forgetting close.

0 Votes 0 ·