• Java的四种引用---强软弱虚


    强软弱虚

    java中的数据被类型分为了两类,它们分别是基本类型和引用类型。一般我们new出来的对象都属于引用类型的范畴。我们知道java是有垃圾回收机制的一种语言,根据垃圾回收时的策略,java将对于堆对象的引用又进行了细分,引用被分为了强引用,软引用,弱引用和虚引用。

    强引用

    强引用又称普通引用,它是最常见的一种引用类型,一般我们通过new关键字创建对象时,变量对于堆对象的引用就是强引用。

    强引用的特点:

    • 如果堆中的一个对象被强引用指向,那么这个变量将不会被GC回收。
    • 在堆内存不够用的情况下,被强引用指向的对象也不会被回收。(宁可抛出OOM异常)
    • 被强引用指向的对象,只有在引用消失后才会被GC回收。

    测试代码-1:

    public class Normal {
        public static void main(String[] args) throws InterruptedException, IOException {
    
            // 栈变量m对new出来的Memory对象的引用为强引用
            Memory m = new Memory(1024 * 1024 * 20);
    
            //现在堆中的对象没有引用指向它,它要被GC回收
            m = null;
    
            System.gc();
    
            //当我们启动java程序是,默认会有两个线程,一个是我们的主线程,另一个是gc线程
            //通常GC线程优先级比较低,并且GC线程默认为守护线程,即它会在主线程退出的同时退出
            //为了观察Gc的效果
            System.in.read();
        }
    }
    
    class Memory{
    
        private byte[] bytes;
    
        public Memory(int size) {
            this.bytes = new byte[size];
        }
    
        @Override
        protected void finalize() throws Throwable {
            super.finalize();
            System.out.println("被GC回收");
        }
    }
    
    //被GC回收
    View Code

    测试代码-2:

    public class Normal1 {
    
        public static void main(String[] args) throws InterruptedException {
    
            // 我们设定jvm参数,设置堆内存大小为25M
            // 栈变量m1对new出来的Memory对象的引用为强引用
            // 申请了20MB的内存,实际会大于20MB,因为我们的byte[]被Memory对象wrapper
            Memory m1 = new Memory(1024 * 1024 * 20);
    
            System.gc();
            Thread.sleep(1000);
    
            // 再申请10MB堆内存
             Memory m2 = new Memory(1024 * 1024 * 10);
        }
    }
    
    //    Connected to the target VM, address: '127.0.0.1:61718', transport: 'socket'
    //        Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    //        at com.cherry.Memory.<init>(Normal.java:32)
    //        at com.cherry.Normal1.main(Normal1.java:14)
    //        Disconnected from the target VM, address: '127.0.0.1:61718', transport: 'socket'
    //
    //        Process finished with exit code 1
    View Code

    软引用

    软引用的创建需要借助jdk中java.lang.ref.SoftReference这个类来创建。也就是说,我们的变量是先引用到SoftReference这个对象,SofReference这个对象再去引用我们想要设置为软引用的对象。 

    软引用的特点

    • 当堆内存够用时,被软引用指向的对象不会被GC回收。
    • 当堆内存不够用时,被软引用指向的对象自动的被GC回收。

    测试代码-3:

    public class Soft_Ref {
    
        public static void main(String[] args) throws InterruptedException {
    
            //堆内存大小为50MB
            SoftReference<Memory> m1 = new SoftReference<>(new Memory(1024 * 1024 * 30));
    
            // 显示调用GC
            System.gc();
    
            // 此时内存够用,所以结果可以预见性的为GC不会回收被软引用指向的对象
            Thread.sleep(1000);
        }
    }
    View Code

     测试代码-4:

    public class Soft_Ref {
    
        public static void main(String[] args) throws InterruptedException {
    
            //堆内存大小为50MB
            SoftReference<Memory> m1 = new SoftReference<>(new Memory(1024 * 1024 * 30));
    
            //申请20MB
            for (int i = 0; i < 20; i++) {
                System.out.println("[time] => " + System.currentTimeMillis());
                SoftReference<Memory> ma = new SoftReference<>(new Memory(1024 * 1024));
                Thread.sleep(200);
            }
        }
    }
    // /Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/bin/java -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:63090,suspend=y,server=n -Xmx50m -javaagent:/Users/qiunan/Library/Caches/IdeaIE2019.3/captureAgent/debugger-agent.jar -Dfile.encoding=UTF-8 -classpath "/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/deploy.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/ext/cldrdata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/ext/jaccess.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/ext/jfxrt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/ext/localedata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/ext/nashorn.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/ext/sunec.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/ext/zipfs.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/javaws.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/jfxswt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/management-agent.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/plugin.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/lib/ant-javafx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/lib/javafx-mx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/lib/packager.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/lib/tools.jar:/Users/qiunan/IdeaProjects/ostream/ostream-web/target/classes:/Users/qiunan/home/local/repo/org/springframework/boot/spring-boot-configuration-processor/2.3.3.RELEASE/spring-boot-configuration-processor-2.3.3.RELEASE.jar:/Users/qiunan/home/local/repo/com/spring4all/swagger-spring-boot-starter/1.9.1.RELEASE/swagger-spring-boot-starter-1.9.1.RELEASE.jar:/Users/qiunan/home/local/repo/io/springfox/springfox-swagger-ui/2.9.2/springfox-swagger-ui-2.9.2.jar:/Users/qiunan/home/local/repo/io/springfox/springfox-spring-web/2.9.2/springfox-spring-web-2.9.2.jar:/Users/qiunan/home/local/repo/io/springfox/springfox-swagger2/2.9.2/springfox-swagger2-2.9.2.jar:/Users/qiunan/home/local/repo/io/swagger/swagger-annotations/1.5.20/swagger-annotations-1.5.20.jar:/Users/qiunan/home/local/repo/io/springfox/springfox-spi/2.9.2/springfox-spi-2.9.2.jar:/Users/qiunan/home/local/repo/io/springfox/springfox-core/2.9.2/springfox-core-2.9.2.jar:/Users/qiunan/home/local/repo/io/springfox/springfox-schema/2.9.2/springfox-schema-2.9.2.jar:/Users/qiunan/home/local/repo/io/springfox/springfox-swagger-common/2.9.2/springfox-swagger-common-2.9.2.jar:/Users/qiunan/home/local/repo/com/google/guava/guava/20.0/guava-20.0.jar:/Users/qiunan/home/local/repo/com/fasterxml/classmate/1.4.0/classmate-1.4.0.jar:/Users/qiunan/home/local/repo/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar:/Users/qiunan/home/local/repo/org/springframework/plugin/spring-plugin-core/1.2.0.RELEASE/spring-plugin-core-1.2.0.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/plugin/spring-plugin-metadata/1.2.0.RELEASE/spring-plugin-metadata-1.2.0.RELEASE.jar:/Users/qiunan/home/local/repo/org/mapstruct/mapstruct/1.2.0.Final/mapstruct-1.2.0.Final.jar:/Users/qiunan/home/local/repo/io/swagger/swagger-models/1.5.24/swagger-models-1.5.24.jar:/Users/qiunan/home/local/repo/com/fasterxml/jackson/core/jackson-annotations/2.9.10/jackson-annotations-2.9.10.jar:/Users/qiunan/home/local/repo/io/springfox/springfox-bean-validators/2.9.2/springfox-bean-validators-2.9.2.jar:/Users/qiunan/home/local/repo/org/springframework/spring-webmvc/5.2.8.RELEASE/spring-webmvc-5.2.8.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/spring-aop/5.2.8.RELEASE/spring-aop-5.2.8.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/spring-beans/5.2.8.RELEASE/spring-beans-5.2.8.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/spring-context/5.2.8.RELEASE/spring-context-5.2.8.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/spring-core/5.2.8.RELEASE/spring-core-5.2.8.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/spring-jcl/5.2.8.RELEASE/spring-jcl-5.2.8.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/spring-expression/5.2.8.RELEASE/spring-expression-5.2.8.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/spring-web/5.2.8.RELEASE/spring-web-5.2.8.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/boot/spring-boot-starter-web/2.3.3.RELEASE/spring-boot-starter-web-2.3.3.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/boot/spring-boot-starter/2.3.3.RELEASE/spring-boot-starter-2.3.3.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/boot/spring-boot/2.3.3.RELEASE/spring-boot-2.3.3.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/boot/spring-boot-autoconfigure/2.3.3.RELEASE/spring-boot-autoconfigure-2.3.3.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/boot/spring-boot-starter-logging/2.3.3.RELEASE/spring-boot-starter-logging-2.3.3.RELEASE.jar:/Users/qiunan/home/local/repo/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar:/Users/qiunan/home/local/repo/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar:/Users/qiunan/home/local/repo/org/apache/logging/log4j/log4j-to-slf4j/2.13.3/log4j-to-slf4j-2.13.3.jar:/Users/qiunan/home/local/repo/org/apache/logging/log4j/log4j-api/2.13.3/log4j-api-2.13.3.jar:/Users/qiunan/home/local/repo/org/slf4j/jul-to-slf4j/1.7.30/jul-to-slf4j-1.7.30.jar:/Users/qiunan/home/local/repo/jakarta/annotation/jakarta.annotation-api/1.3.5/jakarta.annotation-api-1.3.5.jar:/Users/qiunan/home/local/repo/org/yaml/snakeyaml/1.26/snakeyaml-1.26.jar:/Users/qiunan/home/local/repo/org/springframework/boot/spring-boot-starter-json/2.3.3.RELEASE/spring-boot-starter-json-2.3.3.RELEASE.jar:/Users/qiunan/home/local/repo/com/fasterxml/jackson/core/jackson-databind/2.11.2/jackson-databind-2.11.2.jar:/Users/qiunan/home/local/repo/com/fasterxml/jackson/core/jackson-core/2.11.2/jackson-core-2.11.2.jar:/Users/qiunan/home/local/repo/com/fasterxml/jackson/datatype/jackson-datatype-jdk8/2.11.2/jackson-datatype-jdk8-2.11.2.jar:/Users/qiunan/home/local/repo/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.11.2/jackson-datatype-jsr310-2.11.2.jar:/Users/qiunan/home/local/repo/com/fasterxml/jackson/module/jackson-module-parameter-names/2.11.2/jackson-module-parameter-names-2.11.2.jar:/Users/qiunan/home/local/repo/org/springframework/boot/spring-boot-starter-tomcat/2.3.3.RELEASE/spring-boot-starter-tomcat-2.3.3.RELEASE.jar:/Users/qiunan/home/local/repo/org/apache/tomcat/embed/tomcat-embed-core/9.0.37/tomcat-embed-core-9.0.37.jar:/Users/qiunan/home/local/repo/org/glassfish/jakarta.el/3.0.3/jakarta.el-3.0.3.jar:/Users/qiunan/home/local/repo/org/apache/tomcat/embed/tomcat-embed-websocket/9.0.37/tomcat-embed-websocket-9.0.37.jar:/Users/qiunan/home/local/repo/org/springframework/boot/spring-boot-starter-data-jpa/2.3.3.RELEASE/spring-boot-starter-data-jpa-2.3.3.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/boot/spring-boot-starter-aop/2.3.3.RELEASE/spring-boot-starter-aop-2.3.3.RELEASE.jar:/Users/qiunan/home/local/repo/org/aspectj/aspectjweaver/1.9.6/aspectjweaver-1.9.6.jar:/Users/qiunan/home/local/repo/org/springframework/boot/spring-boot-starter-jdbc/2.3.3.RELEASE/spring-boot-starter-jdbc-2.3.3.RELEASE.jar:/Users/qiunan/home/local/repo/com/zaxxer/HikariCP/3.4.5/HikariCP-3.4.5.jar:/Users/qiunan/home/local/repo/org/springframework/spring-jdbc/5.2.8.RELEASE/spring-jdbc-5.2.8.RELEASE.jar:/Users/qiunan/home/local/repo/jakarta/transaction/jakarta.transaction-api/1.3.3/jakarta.transaction-api-1.3.3.jar:/Users/qiunan/home/local/repo/jakarta/persistence/jakarta.persistence-api/2.2.3/jakarta.persistence-api-2.2.3.jar:/Users/qiunan/home/local/repo/org/hibernate/hibernate-core/5.4.20.Final/hibernate-core-5.4.20.Final.jar:/Users/qiunan/home/local/repo/org/jboss/logging/jboss-logging/3.3.2.Final/jboss-logging-3.3.2.Final.jar:/Users/qiunan/home/local/repo/org/javassist/javassist/3.24.0-GA/javassist-3.24.0-GA.jar:/Users/qiunan/home/local/repo/net/bytebuddy/byte-buddy/1.10.10/byte-buddy-1.10.10.jar:/Users/qiunan/home/local/repo/antlr/antlr/2.7.7/antlr-2.7.7.jar:/Users/qiunan/home/local/repo/org/jboss/jandex/2.1.3.Final/jandex-2.1.3.Final.jar:/Users/qiunan/home/local/repo/org/dom4j/dom4j/2.1.3/dom4j-2.1.3.jar:/Users/qiunan/home/local/repo/org/hibernate/common/hibernate-commons-annotations/5.1.0.Final/hibernate-commons-annotations-5.1.0.Final.jar:/Users/qiunan/home/local/repo/org/glassfish/jaxb/jaxb-runtime/2.3.1/jaxb-runtime-2.3.1.jar:/Users/qiunan/home/local/repo/org/glassfish/jaxb/txw2/2.3.1/txw2-2.3.1.jar:/Users/qiunan/home/local/repo/com/sun/istack/istack-commons-runtime/3.0.7/istack-commons-runtime-3.0.7.jar:/Users/qiunan/home/local/repo/org/jvnet/staxex/stax-ex/1.8/stax-ex-1.8.jar:/Users/qiunan/home/local/repo/com/sun/xml/fastinfoset/FastInfoset/1.2.15/FastInfoset-1.2.15.jar:/Users/qiunan/home/local/repo/org/springframework/data/spring-data-jpa/2.3.3.RELEASE/spring-data-jpa-2.3.3.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/data/spring-data-commons/2.3.3.RELEASE/spring-data-commons-2.3.3.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/spring-orm/5.2.8.RELEASE/spring-orm-5.2.8.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/spring-tx/5.2.8.RELEASE/spring-tx-5.2.8.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/spring-aspects/5.2.8.RELEASE/spring-aspects-5.2.8.RELEASE.jar:/Users/qiunan/home/local/repo/mysql/mysql-connector-java/5.1.49/mysql-connector-java-5.1.49.jar:/Users/qiunan/home/local/repo/org/apache/commons/commons-lang3/3.11/commons-lang3-3.11.jar:/Users/qiunan/home/local/repo/org/apache/httpcomponents/httpclient/4.5.12/httpclient-4.5.12.jar:/Users/qiunan/home/local/repo/org/apache/httpcomponents/httpcore/4.4.13/httpcore-4.4.13.jar:/Users/qiunan/home/local/repo/commons-logging/commons-logging/1.2/commons-logging-1.2.jar:/Users/qiunan/home/local/repo/commons-codec/commons-codec/1.11/commons-codec-1.11.jar:/Applications/IntelliJ IDEA Edu.app/Contents/lib/idea_rt.jar" com.cherry.Soft_Ref
    //         Connected to the target VM, address: '127.0.0.1:63090', transport: 'socket'
    //         [time] => 1602066284309
    //         [time] => 1602066284514
    //         [time] => 1602066284720
    //         [time] => 1602066284925
    //         [time] => 1602066285129
    //         [time] => 1602066285333
    //         [time] => 1602066285538
    //         [time] => 1602066285744
    //         [time] => 1602066285947
    //         被GC回收
    //         被GC回收
    //         被GC回收
    //         被GC回收
    //         被GC回收
    //         被GC回收
    //         被GC回收
    //         被GC回收
    //         [time] => 1602066286161
    //         [time] => 1602066286364
    //         [time] => 1602066286565
    //         [time] => 1602066286766
    //         [time] => 1602066286971
    //         [time] => 1602066287176
    //         被GC回收
    //         被GC回收
    //         被GC回收
    //         被GC回收
    //         被GC回收
    //         被GC回收
    //         [time] => 1602066287384
    //         [time] => 1602066287588
    //         [time] => 1602066287791
    //         [time] => 1602066287994
    //         [time] => 1602066288198
    //         Disconnected from the target VM, address: '127.0.0.1:63090', transport: 'socket'
    //
    //         Process finished with exit code 0
    View Code

    从测试结果可以看出,当内存不够用或者将要不够用时,会触发GC,GC会自动的回收那些软引用指向对象。

    一定要注意,软引用指向对象的回收是在触发GC的条件下才会被回收,如果内存够用,就算显式的调用GC,软引用指向的对象也不会被回收。

    弱引用

    弱引用的创建方式与软引用类似,需要借助于jdk中java.lang.ref.WeakReference类去创建

    弱引用的特点:

    • 不管什么情况,遇到GC就会回收被弱引用指向的对象。

     测试代码-5:

    public class Weak_Ref {
    
        public static void main(String[] args) throws InterruptedException {
    
            // 堆内存没有设置,为默认状态
            WeakReference<Memory> m = new WeakReference<>(new Memory(1024 * 1024 * 10));
    
            // 调用GC
            System.gc();
    
            Thread.sleep(1000);
        }
    }
    
    //被GC回收
    View Code

    虚引用

    虚引用是一种十分特殊的引用,它主要用在堆外内存的管理,虚引用可以指向堆中的对象,但是没有实际的意义。

    DirectByteBuffer是Java用于实现堆外内存的一个重要类,我们可以通过该类实现堆外内存的创建、使用和销毁。

    当对象被回收时,通过Queue可以检测到,然后清理堆外内存。

     虚引用的特点:

    • 无法获取虚引用指向的对象的值。
    • 虚引用在被GC回收时会有通知。
    • 虚引用在遇到GC时,不管是否还有对象引用它,它都会被GC回收。

     测试代码-6:

    public class Phantom_Ref {
    
        static final ArrayList<byte[]> LIST = new ArrayList<>();
    
        static final ReferenceQueue<Memory> QUEUE = new ReferenceQueue<>();
    
        public static void main(String[] args) {
    
            PhantomReference<Memory> m = new PhantomReference<>(new Memory(1024 * 1024 * 10), QUEUE);
            new Thread(()->{
                while (true) {
                    LIST.add(new byte[1024 * 1024 ]);
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                        Thread.currentThread().interrupt();
                    }
                    // 虚引用指向的值永远无法被获取
                    System.out.println(m.get());
                }
            }).start();
    
            new Thread(() -> {
                while (true) {
                    Reference<? extends  Memory> poll = QUEUE.poll();
                    if (poll != null) {
                        //虚引用在对象被回收时,会进行通知
                        System.out.println("有虚引用被GC回收了-" + poll);
                        break;
                    }
                }
            }).start();
        }
    }
    
    ///Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/bin/java -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:63862,suspend=y,server=n -Xmx20m -javaagent:/Users/qiunan/Library/Caches/IdeaIE2019.3/captureAgent/debugger-agent.jar -Dfile.encoding=UTF-8 -classpath "/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/deploy.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/ext/cldrdata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/ext/dnsns.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/ext/jaccess.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/ext/jfxrt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/ext/localedata.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/ext/nashorn.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/ext/sunec.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/ext/zipfs.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/javaws.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/jfxswt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/management-agent.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/plugin.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/lib/ant-javafx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/lib/dt.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/lib/javafx-mx.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/lib/jconsole.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/lib/packager.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/lib/sa-jdi.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/lib/tools.jar:/Users/qiunan/IdeaProjects/ostream/ostream-web/target/classes:/Users/qiunan/home/local/repo/org/springframework/boot/spring-boot-configuration-processor/2.3.3.RELEASE/spring-boot-configuration-processor-2.3.3.RELEASE.jar:/Users/qiunan/home/local/repo/com/spring4all/swagger-spring-boot-starter/1.9.1.RELEASE/swagger-spring-boot-starter-1.9.1.RELEASE.jar:/Users/qiunan/home/local/repo/io/springfox/springfox-swagger-ui/2.9.2/springfox-swagger-ui-2.9.2.jar:/Users/qiunan/home/local/repo/io/springfox/springfox-spring-web/2.9.2/springfox-spring-web-2.9.2.jar:/Users/qiunan/home/local/repo/io/springfox/springfox-swagger2/2.9.2/springfox-swagger2-2.9.2.jar:/Users/qiunan/home/local/repo/io/swagger/swagger-annotations/1.5.20/swagger-annotations-1.5.20.jar:/Users/qiunan/home/local/repo/io/springfox/springfox-spi/2.9.2/springfox-spi-2.9.2.jar:/Users/qiunan/home/local/repo/io/springfox/springfox-core/2.9.2/springfox-core-2.9.2.jar:/Users/qiunan/home/local/repo/io/springfox/springfox-schema/2.9.2/springfox-schema-2.9.2.jar:/Users/qiunan/home/local/repo/io/springfox/springfox-swagger-common/2.9.2/springfox-swagger-common-2.9.2.jar:/Users/qiunan/home/local/repo/com/google/guava/guava/20.0/guava-20.0.jar:/Users/qiunan/home/local/repo/com/fasterxml/classmate/1.4.0/classmate-1.4.0.jar:/Users/qiunan/home/local/repo/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar:/Users/qiunan/home/local/repo/org/springframework/plugin/spring-plugin-core/1.2.0.RELEASE/spring-plugin-core-1.2.0.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/plugin/spring-plugin-metadata/1.2.0.RELEASE/spring-plugin-metadata-1.2.0.RELEASE.jar:/Users/qiunan/home/local/repo/org/mapstruct/mapstruct/1.2.0.Final/mapstruct-1.2.0.Final.jar:/Users/qiunan/home/local/repo/io/swagger/swagger-models/1.5.24/swagger-models-1.5.24.jar:/Users/qiunan/home/local/repo/com/fasterxml/jackson/core/jackson-annotations/2.9.10/jackson-annotations-2.9.10.jar:/Users/qiunan/home/local/repo/io/springfox/springfox-bean-validators/2.9.2/springfox-bean-validators-2.9.2.jar:/Users/qiunan/home/local/repo/org/springframework/spring-webmvc/5.2.8.RELEASE/spring-webmvc-5.2.8.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/spring-aop/5.2.8.RELEASE/spring-aop-5.2.8.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/spring-beans/5.2.8.RELEASE/spring-beans-5.2.8.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/spring-context/5.2.8.RELEASE/spring-context-5.2.8.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/spring-core/5.2.8.RELEASE/spring-core-5.2.8.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/spring-jcl/5.2.8.RELEASE/spring-jcl-5.2.8.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/spring-expression/5.2.8.RELEASE/spring-expression-5.2.8.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/spring-web/5.2.8.RELEASE/spring-web-5.2.8.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/boot/spring-boot-starter-web/2.3.3.RELEASE/spring-boot-starter-web-2.3.3.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/boot/spring-boot-starter/2.3.3.RELEASE/spring-boot-starter-2.3.3.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/boot/spring-boot/2.3.3.RELEASE/spring-boot-2.3.3.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/boot/spring-boot-autoconfigure/2.3.3.RELEASE/spring-boot-autoconfigure-2.3.3.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/boot/spring-boot-starter-logging/2.3.3.RELEASE/spring-boot-starter-logging-2.3.3.RELEASE.jar:/Users/qiunan/home/local/repo/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar:/Users/qiunan/home/local/repo/ch/qos/logback/logback-core/1.2.3/logback-core-1.2.3.jar:/Users/qiunan/home/local/repo/org/apache/logging/log4j/log4j-to-slf4j/2.13.3/log4j-to-slf4j-2.13.3.jar:/Users/qiunan/home/local/repo/org/apache/logging/log4j/log4j-api/2.13.3/log4j-api-2.13.3.jar:/Users/qiunan/home/local/repo/org/slf4j/jul-to-slf4j/1.7.30/jul-to-slf4j-1.7.30.jar:/Users/qiunan/home/local/repo/jakarta/annotation/jakarta.annotation-api/1.3.5/jakarta.annotation-api-1.3.5.jar:/Users/qiunan/home/local/repo/org/yaml/snakeyaml/1.26/snakeyaml-1.26.jar:/Users/qiunan/home/local/repo/org/springframework/boot/spring-boot-starter-json/2.3.3.RELEASE/spring-boot-starter-json-2.3.3.RELEASE.jar:/Users/qiunan/home/local/repo/com/fasterxml/jackson/core/jackson-databind/2.11.2/jackson-databind-2.11.2.jar:/Users/qiunan/home/local/repo/com/fasterxml/jackson/core/jackson-core/2.11.2/jackson-core-2.11.2.jar:/Users/qiunan/home/local/repo/com/fasterxml/jackson/datatype/jackson-datatype-jdk8/2.11.2/jackson-datatype-jdk8-2.11.2.jar:/Users/qiunan/home/local/repo/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.11.2/jackson-datatype-jsr310-2.11.2.jar:/Users/qiunan/home/local/repo/com/fasterxml/jackson/module/jackson-module-parameter-names/2.11.2/jackson-module-parameter-names-2.11.2.jar:/Users/qiunan/home/local/repo/org/springframework/boot/spring-boot-starter-tomcat/2.3.3.RELEASE/spring-boot-starter-tomcat-2.3.3.RELEASE.jar:/Users/qiunan/home/local/repo/org/apache/tomcat/embed/tomcat-embed-core/9.0.37/tomcat-embed-core-9.0.37.jar:/Users/qiunan/home/local/repo/org/glassfish/jakarta.el/3.0.3/jakarta.el-3.0.3.jar:/Users/qiunan/home/local/repo/org/apache/tomcat/embed/tomcat-embed-websocket/9.0.37/tomcat-embed-websocket-9.0.37.jar:/Users/qiunan/home/local/repo/org/springframework/boot/spring-boot-starter-data-jpa/2.3.3.RELEASE/spring-boot-starter-data-jpa-2.3.3.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/boot/spring-boot-starter-aop/2.3.3.RELEASE/spring-boot-starter-aop-2.3.3.RELEASE.jar:/Users/qiunan/home/local/repo/org/aspectj/aspectjweaver/1.9.6/aspectjweaver-1.9.6.jar:/Users/qiunan/home/local/repo/org/springframework/boot/spring-boot-starter-jdbc/2.3.3.RELEASE/spring-boot-starter-jdbc-2.3.3.RELEASE.jar:/Users/qiunan/home/local/repo/com/zaxxer/HikariCP/3.4.5/HikariCP-3.4.5.jar:/Users/qiunan/home/local/repo/org/springframework/spring-jdbc/5.2.8.RELEASE/spring-jdbc-5.2.8.RELEASE.jar:/Users/qiunan/home/local/repo/jakarta/transaction/jakarta.transaction-api/1.3.3/jakarta.transaction-api-1.3.3.jar:/Users/qiunan/home/local/repo/jakarta/persistence/jakarta.persistence-api/2.2.3/jakarta.persistence-api-2.2.3.jar:/Users/qiunan/home/local/repo/org/hibernate/hibernate-core/5.4.20.Final/hibernate-core-5.4.20.Final.jar:/Users/qiunan/home/local/repo/org/jboss/logging/jboss-logging/3.3.2.Final/jboss-logging-3.3.2.Final.jar:/Users/qiunan/home/local/repo/org/javassist/javassist/3.24.0-GA/javassist-3.24.0-GA.jar:/Users/qiunan/home/local/repo/net/bytebuddy/byte-buddy/1.10.10/byte-buddy-1.10.10.jar:/Users/qiunan/home/local/repo/antlr/antlr/2.7.7/antlr-2.7.7.jar:/Users/qiunan/home/local/repo/org/jboss/jandex/2.1.3.Final/jandex-2.1.3.Final.jar:/Users/qiunan/home/local/repo/org/dom4j/dom4j/2.1.3/dom4j-2.1.3.jar:/Users/qiunan/home/local/repo/org/hibernate/common/hibernate-commons-annotations/5.1.0.Final/hibernate-commons-annotations-5.1.0.Final.jar:/Users/qiunan/home/local/repo/org/glassfish/jaxb/jaxb-runtime/2.3.1/jaxb-runtime-2.3.1.jar:/Users/qiunan/home/local/repo/org/glassfish/jaxb/txw2/2.3.1/txw2-2.3.1.jar:/Users/qiunan/home/local/repo/com/sun/istack/istack-commons-runtime/3.0.7/istack-commons-runtime-3.0.7.jar:/Users/qiunan/home/local/repo/org/jvnet/staxex/stax-ex/1.8/stax-ex-1.8.jar:/Users/qiunan/home/local/repo/com/sun/xml/fastinfoset/FastInfoset/1.2.15/FastInfoset-1.2.15.jar:/Users/qiunan/home/local/repo/org/springframework/data/spring-data-jpa/2.3.3.RELEASE/spring-data-jpa-2.3.3.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/data/spring-data-commons/2.3.3.RELEASE/spring-data-commons-2.3.3.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/spring-orm/5.2.8.RELEASE/spring-orm-5.2.8.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/spring-tx/5.2.8.RELEASE/spring-tx-5.2.8.RELEASE.jar:/Users/qiunan/home/local/repo/org/springframework/spring-aspects/5.2.8.RELEASE/spring-aspects-5.2.8.RELEASE.jar:/Users/qiunan/home/local/repo/mysql/mysql-connector-java/5.1.49/mysql-connector-java-5.1.49.jar:/Users/qiunan/home/local/repo/org/apache/commons/commons-lang3/3.11/commons-lang3-3.11.jar:/Users/qiunan/home/local/repo/org/apache/httpcomponents/httpclient/4.5.12/httpclient-4.5.12.jar:/Users/qiunan/home/local/repo/org/apache/httpcomponents/httpcore/4.4.13/httpcore-4.4.13.jar:/Users/qiunan/home/local/repo/commons-logging/commons-logging/1.2/commons-logging-1.2.jar:/Users/qiunan/home/local/repo/commons-codec/commons-codec/1.11/commons-codec-1.11.jar:/Applications/IntelliJ IDEA Edu.app/Contents/lib/idea_rt.jar" com.cherry.Phantom_Ref
    //        Connected to the target VM, address: '127.0.0.1:63862', transport: 'socket'
    //        被GC回收
    //        null
    //        null
    //        null
    //        null
    //        有虚引用被GC回收了-java.lang.ref.PhantomReference@5be60800
    //        null
    //        null
    //        null
    //        null
    //        Exception in thread "Thread-0" java.lang.OutOfMemoryError: Java heap space
    //        at com.cherry.Phantom_Ref.lambda$main$0(Phantom_Ref.java:24)
    //        at com.cherry.Phantom_Ref$$Lambda$1/1781256139.run(Unknown Source)
    //        at java.lang.Thread.run(Thread.java:748)
    //        Disconnected from the target VM, address: '127.0.0.1:63862', transport: 'socket'
    //
    //        Process finished with exit code 0
    View Code
  • 相关阅读:
    wmq的A×B Problem
    MATLAB 求系统的单位冲击响应及单位阶跃响应
    关于共享率过低的一些事
    Vue组件之间的通信
    浏览器支持ES6的import和export
    Vue axios拦截问题
    开屏倒计时
    git常用操作
    原型
    this指向问题
  • 原文地址:https://www.cnblogs.com/vip-nange/p/13945778.html
Copyright © 2020-2023  润新知