Forced garbage collection

Source: Internet
Author: User

When an object is out of reference, the system verifies that its finalize () is called to clean up its resources and verifies that it will become dead. The system verifies that the memory occupied by the object is reclaimed.ProgramIt is completely transparent. The program can only control an object to verify that it is no longer referenced by any referenced variable, and never control when it is recycled.

The program cannot accurately control the timing of Java garbage collection, but we can still force the system to do garbage collection-only this kind of Force notifies the system to do garbage collection, but the system is still not sure whether to do garbage collection. There are two methods to force garbage collection:

1. Call the GC () static method of the system class: system. GC ();

2. Call the GC () instance method of the runtime object: runtime. getruntime (). GC ()

Three State Transformations of an object:

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.