Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Programming \ Java objects to garbage collection     - Linux processes in memory and memory cgroup statistics (Linux)

- Docker Build a Java compiler environment (Linux)

- Hadoop connection failed or stuck processing (Server)

- ORA-04031 error appears in the solution run utlrp.sql (Database)

- MySQL & NoSQL - Memcached widget (Database)

- Change CentOS 7 NIC name eno16777736 to eth0 (Linux)

- Install Redis 2.6 5.5 32 position CentOS error resolved (Linux)

- Linux system security configuration (Linux)

- GAMIT10.5 install and update failed Solution (Linux)

- C ++ Supplements - locates the new expression (Programming)

- Linux install deploy Ansible (Linux)

- Linux kernel VLAN study notes (Programming)

- DBCA Error: ORA-19809: limit exceeded for recovery files process (Database)

- To_explore Linux system boot process (Linux)

- grep command output highlighted word (Linux)

- Linux LVM space expansion Demo (Linux)

- Lambda expressions of evolution (Programming)

- Make Windows boot disk to install USB in Ubuntu Linux (Linux)

- In addition to wget and curl, what better alternatives (Linux)

- Java Prototype Pattern (Programming)

  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 ()..
- Linux regex sed detailing (Linux)
- 10 Nginx safety tips (Linux)
- To explore the caching mechanism for Android ListView (Programming)
- To_teach you three strategies to prevent the LAN IP address theft (Linux)
- How to Install Node.js in CentOS 7 (Linux)
- Advanced Linux security settings (Linux)
- DataGuard Standby backup error RMAN-06820 ORA-17629 to solve (Database)
- Use Hexo quickly build and deploy a blog to Github (Server)
- Use calcurse schedule appointments and to-do in the Linux terminal (Linux)
- Android judgment toward camera pictures (Programming)
- How to Install SeaMonkey 2.25 for Ubuntu (Linux)
- CentOS boot image to achieve semi-automatic installation (Linux)
- SA weak password security system of the security risks posed (Linux)
- Spring AOP for logging (Programming)
- How to interactively create a Docker container (Server)
- Docker knowledge base (Server)
- Cobbler remotely install CentOS system (Linux)
- C ++ hash function (Programming)
- Postgres-X2 deployment steps (Database)
- Circular list of Java programming (Programming)
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.