I have a Java code that I have been testing, the code uses the scanner class without closing it. I know that this causes memory leaks and that the memory that was occupied by the scanner resources during the code execution is still occupied by the scanner resources even after the code finishes its' execution. I know closing the scanner helps prevent this issue, but for the times the code has been tested without closing the scanner class, does restarting the computer free up the memory that was taken by the scanner class when it wasn't closed after the code's execution?
To expand on Stephans answer:
So from my understanding, when a Java Program (Application or whatever) is started, a Java Virtual Machine (JVM) is instantiated. This is what will provide and consume all the memory etc. that your program requires. When the Scanner class is scanning files, it will ask the JVM for file handles (these are the things that get handed back when the Scanner is closed), these may run out - which is why you need to close your Scanners (or use the Java 8+ try with resources).
It is the JVM which needs to be restarted, not the computer running the JVM.