JAVA VS C/C++ 記憶體回收機制 [JAVA VS CPP Garbage Collection] 寫實有趣動畫

JAVA VS C/C++ 記憶體回收機制 [JAVA VS CPP Garbage Collection] 寫實有趣動畫

JAVA VS C/C++ 記憶體回收機制 [JAVA VS CPP Garbage Collection] 寫實有趣動畫


GITHUB: https://github.com/jash-git/JAVA-VS-CPP-Garbage-Collection



C++                          VS     JAVA



   VS   

One thought on “JAVA VS C/C++ 記憶體回收機制 [JAVA VS CPP Garbage Collection] 寫實有趣動畫

  1. //JAVA ONELINE 測試

    //https://www.tutorialspoint.com/online_java_compiler.php

    //確定 System.gc(); 和 指定NULL 豆JAVA都是參考用

    public class GcTest {
    private String name;
    public GcTest(String name)
    {
    this.name = name;
    System.out.println(name + “Create”);
    }
    protected void finalize()
    {
    System.out.println(name + “Delete”);
    }
    }
    public class HelloWorld{

    public static void main(String []args){
    System.out.println(“Hello World…000”);
    GcTest obj1 = new GcTest(“object1…”);
    GcTest obj2 = new GcTest(“object2…”);
    GcTest obj3 = new GcTest(“object3…”);
    System.out.println(“Hello World…001”);

    obj1 = null;
    obj2 = null;
    obj3 = null;
    System.out.println(“Hello World…002”);
    System.gc();
    System.out.println(“Hello World…003”);

    }
    }
    /*
    Hello World…000
    object1…Create
    object2…Create
    object3…Create
    Hello World…001
    Hello World…002
    Hello World…003
    object1…Delete
    object3…Delete
    object2…Delete
    */

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *