JVM tuning combat - What is garbage collection and Java's automatic garbage collection GC

What is garbage collection

Is bound to run the program for memory resources, invalid object resources if not promptly treated will always take up memory resources will eventually lead to memory overflow, the management of memory resources becomes very important.

Garbage collection C / C ++ language

In the C / C ++ language, there is no automatic garbage collection mechanism is the application memory resources through new keywords, free up memory resources by the delete key.

If the program ape in some locations did not write delete to be released, then the application will have been the object memory resources (memory leaks), may eventually lead to memory overflow.

Garbage collection JAVA language

In order to make the program ape to focus more on implementation code, and memory problems without too much consideration of release, so the java language, with automatic garbage collection mechanism, that is, we are familiar with GC.

With garbage collection mechanism, the program ape only care about the memory of the application can release memory automatically recognized by the system to complete.

In other words, automatic garbage collection algorithms will become very important, because if the algorithm is unreasonable, leading to memory resource has not been released, it is also likely to lead to memory overflow.

Of course, in addition to the java language, C #, Python and other languages ​​with automatic garbage collection mechanism.

Published 824 original articles · won praise 369 · views 790 000 +

Guess you like

Origin blog.csdn.net/a772304419/article/details/104002254