Java memory leaks - Cleared upon program terminati

2020-04-21 05:49发布

问题:

This seems like a yes or no question, and I would have expected it to be answered somewhere but I certainly can't find it. Memory leaks in java don't happen as often as as say developing in a language like C or C++, but they can happen.

Most OS will clear memory allocated upon a program's termination, with exception to certain cases like shared memory. Is this still true for when the JVM exits? If I inadvertently create a memory leak in Java will it be cleared by either the JVM or a Linux or Windows OS?

回答1:

Yes,all memory will be released after JVM terminated.