Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Programming \ Java objects to garbage collection     - Sublime Text 3 shortcuts summary (Linux)

- MySQLbinlog combat on using data recovery (Database)

- Oracle user lock how to know what causes (Database)

- Windows Desktop use VNC remote connect Linux (Linux)

- MySQL stored procedures execute dynamic sql statement (Database)

- Linux Detailed instructions alias settings (Linux)

- How to release the cache memory on Linux (Linux)

- Python exception summary (Programming)

- Fun music library in Linux using command line (Linux)

- The Linux role of each directory contents (Linux)

- C # compiler to achieve functional use in the runtime (Programming)

- sudoers file parsing (Linux)

- Google open source TCP team repaired the Linux kernel TCP flaw (Linux)

- Ansible installation configuration and simple to use (Server)

- Android Custom View password box example (Programming)

- Linux (RHEL6 CENTOS6 OLE6) VNC-SERVER Installation and Configuration (Server)

- MySQL 5.5 on master-slave copy filter (Database)

- Kali Linux 2.0 U disk installation errors Your installation cd-rom could not be mounted (Linux)

- Java List add duplicate the same object (Programming)

- CentOS6.5 setup Oracle 11gR2 startup (Database)

  Java objects to garbage collection
  Add Date : 2018-11-21      
  1. Garbage collection mechanism is only responsible for recycling heap objects in memory and will not recover any physical resources (such as database connections, network IO and other resources)

2. The program can not accurately control the garbage collection operation, the garbage collector runs at the right time. When the object is a permanent loss of reference, the system will recover its occupied memory at the right time.

3. Before any objects recovered in garbage collection, there is always the first to call its finalize () method.

Object in memory state:

Reachable state: When an object is created, if more than one reference variable reference to him, then the object is reachable in the program, the program can be called instance variables and methods of the object variable by reference.

Recoverable state: If the program is not a variable in any reference variables refer to it, it enters a recoverable state. In this state, the garbage collection mechanism will be ready to reclaim the variable corresponding to the memory, prior to recovery of the object, the system calls used to restore the object fnalize () method, if at this time there is a reference to the object variable reference, the Object re become unreachable.

Unreachable: when used in reference objects and variable contact is cut off, and the system has been called the object's finalize () method, still does not make the object becomes unreachable. In this case the object into the unreachable state, only when the object is unreachable, the system will begin recycling the resources occupied by the object.

public class StatusTranfer {
    public static void test () {
        // When performing this step, the object is reachable 12345
        String a = new String ( "12345");
        // Perform this step when the object 12345 in a recoverable state
        // Objects up to 123 in state
        a = new String ( "123");
    public static void main (String [] args) {
        test ();

Mandatory garbage collection
      Program can control when a target is not referenced variable references, but you can not control when garbage collection.

      Java program can not precisely control the timing of garbage collection, but still be able to force the garbage collection system ---- such coercion only notification system for garbage collection, but the garbage collection system is still uncertain. Most of the time, the program forces the system garbage collection will have some effect.

Mandatory garbage collection in two ways:

1. Static class method call System gc (): System.gc ()

2. Call Runtime's gc () instance method: Runtime.getRuntime () gc ()..
- System with Windows Remote Desktop to connect Ubuntu 15.04 (Linux)
- Debugging with GDB tool Go (Programming)
- Binding unofficial Google Drive and Ubuntu 14.04 LTS (Linux)
- Hadoop upload files error solved (Server)
- Android Studio simple setup (Linux)
- To install the latest version of the EPEL on CentOS 5.x or 6.x (Linux)
- C ++ in the elimination Wunused (Programming)
- PuTTY Xming achieve the X11 forwarding ssh (Server)
- ORA-27054 NFS problem solving (Database)
- Linux Command Line Art (Linux)
- Get basic information about Linux server script (Server)
- Unable to solve the official version of Android Studio online update problem (Linux)
- Optimized to minimize the installation of CentOS 5.8 (Linux)
- Installation Strongswan: on a Linux IPsec-based VPN tool (Linux)
- Appweb configuration in detail (Server)
- Install Web-based monitoring tool: Linux-Dash (Server)
- Java threads in the life cycle (Programming)
- Solaris 11 forget the root password (Linux)
- Text analysis tools - awk (Linux)
- CentOS 6.5 x86_64 system customized automated deployment (Linux)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.