java中的引用默认是强引用(StrongReference),必须等所有对对象的引用断开才能标识为垃圾;
弱引用:只要JVM需要内存就可以回收,无需等引用断开。
弱引用用法:SoftReference<String> sRef = new SoftReference<String>(new String("asdfas"));
String str = sRef.get();
java中的引用默认是强引用(StrongReference),必须等所有对对象的引用断开才能标识为垃圾;
弱引用:只要JVM需要内存就可以回收,无需等引用断开。
弱引用用法:SoftReference<String> sRef = new SoftReference<String>(new String("asdfas"));
String str = sRef.get();
转载于:https://www.cnblogs.com/until-dead/p/3576506.html