JVM - Are WeakReferences collected in minor GC?

前端 未结 6 1057
情歌与酒
情歌与酒 2021-01-05 11:06

I was wondering about that since that would make them less useful. If so, is there a way to make memory weakly referenced only \"garbage\" on major GC?

6条回答
  •  北荒
    北荒 (楼主)
    2021-01-05 11:19

    It will depend if the WeakReference object is in Eden or not - a minor collection will only look at objects in Eden.

提交回复
热议问题