<!DOCTYPE html> <html> <head> <meta charset=_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:29:33
Original
2360 people have browsed it

Java引用和gc.mdown—/Users/wjk/Desktop/笔记

强引用

强引用是我们接触最多的引用,若果是强引用JVM宁愿抛出OOM也不愿回收具有强引用的对象。
Copy after login

软引用

具有软引用的对象,内存空间充足的时候,垃圾回收器不会回收,当内存空间不充足的时候,垃圾回收器回收。
Copy after login

弱引用

在垃圾回收器线程扫描它所管辖的内存区域的过程中,一旦发现了只具有弱引用的对象,不管当前内存空间足够与否,都会回收它的内存。
Copy after login

虚引用

虚引用主要用来跟踪对象被垃圾回收器回收的活动。虚引用与软引用和弱引用的一个区别在于:虚引用必须和引用队列 (ReferenceQueue)联合使用。当垃圾回收器准备回收一个对象时,如果发现它还有虚引用,就会在回收对象的内存之前,把这个虚引用加入到与之关联的引用队列中。
Copy after login

引用队列

软引用、弱引用可以和一个引用队列(ReferenceQueue)联合使用,如果软引用所引用的对象被垃圾回收器回收,Java虚拟机就会把这个软引用加入到与之关联的引用队列中。
Copy after login

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!