Runtime类之中提供了几个管理内存的方法
    maxMemory
    totalMemory
    freeMemory
    堆内存溢出错误OutOfMemoryError
    Object类中有一个finalize方法 如果重写也能看见对象回收
    GC系统提供的一个线程 回收算法

    内存管理的问题
    栈内存——变量空间 方法临时执行空间 从创建开始执行完毕 立即回收
    堆内存——我们自己new申请对象空间 垃圾回收器GC 对象空间没有任何引用指向视为垃圾
    方法区——常量 类模板 静态成员 有且只有一份 不回收
    public class Test{
    public Person p = new Person();//聚合关系
    }
    Test t = new Test();
    Person p = t.p;
    p = null;
    t.p = null;
    System.gc();
    为了能看到对象被回收的效果
    1.重写类中的finalize方法 从Object继承过来的
    2.Runtime类 单例模式 Runtime.getRuntime();获取对象
    long = maxMemory totalMemory freeMemory
    OutOfMemoryError 堆内存溢出错误
    StackOverflowError 栈内存溢出错误

    内存空间.jpg