Is it possible to mark java objects non-collectable from gc perspective to save on gc-sweep time?

后端 未结 5 1096
独厮守ぢ
独厮守ぢ 2021-01-04 21:26

Is it possible to mark java objects non-collectable from gc perspective to save on gc-sweep time?

Something along the lines of http://wwwasd.web.cern.ch/wwwasd/lhc++

5条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-04 21:35

    Is it possible to mark java objects non-collectable from gc perspective to save on gc-sweep time?

    No it is not possible.

    You can prevent objects from being garbage collected by keeping them reachable, but the GC will still need to trace them to check reachability on each full; GC (at least).

    Is simply my assumption, that when the jvm is starving it begins scanning all those unnecessary objects too.

    Yes. That is correct. However, unless you've got LOTS of objects that you want to be treated this way, the overhead is likely to be insignificant. (And anyway, a better idea is to give the JVM more memory ... if that is possible.)

提交回复
热议问题