Java garbage collection mechanism

Source: Internet
Author: User

The Java platform automates memory management through the garbage collector (GC) and is primarily responsible for completing 3 tasks: allocating memory, ensuring that the referenced object's memory is not being reclaimed incorrectly, and reclaim memory space for objects that are no longer referenced. In general, the execution of the entire application is temporarily aborted when the garbage collector is in the recycling operation. Because the garbage collector is updating the actual memory address referenced by all objects in the app. The garbage collection methods supported by different hardware platforms are also different.

The most basic method of garbage collection is recycling. Memory is divided into generations (young, old, and permanent), objects are stored in the corresponding generation region according to their survival time, and different generations of garbage collection algorithms vary. Memory allocations occur in young generations. When an object survives long enough, it is copied to the old age.

Java provides 3 kinds of garbage collection mechanisms:

Serial Recycling : Use a single CPU to reclaim the memory of younger and older generations, suitable for a typical single CPU desktop platform. During the garbage collection process, the application is temporarily aborted. Recycling is using generational recycling.

Parallel Recycling : When a young generation is recycled in this way, multiple CPU parallel processing is used to improve recovery performance. Out;

parallel tagging--clear recycle : You can tag live objects and recycle garbage while the app is running, just for a short time to abort the application, which is appropriate for applications with high response time requirements.

Java garbage collection mechanism

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.