Doubts on Garbage Collection in java

前端 未结 2 1951
长发绾君心
长发绾君心 2021-02-10 03:11

I know lots of question have been asked about Garbage Collection and I have gone through them, but I still have have some doubts.

  1. If we cannot force the JVM fo

2条回答
  •  走了就别回头了
    2021-02-10 04:07

    1) The often repeated statement is true and yet misleading. The specification of the method (i.e. the javadocs) are phrased in a way that make a noop implementation valid. In other words, there are no spec-guarantees that it does anything or only do something asynchronously or whatever.

    But implementations can provide much stronger behavior. In other words, what people should be saying is that System.gc is implementation- and configuration-dependent and under some circumstances does consistently trigger a GC on every call.

    2) Perm gen is an implementation detail of the hotspot JVM prior to java 8.

    3) They aren't

    4) "Application" is too fuzzy, you could run multiple applications on a shared JVM. There is one managed heap per JVM.

    5) Those are two separate questions.

    6) Depends on the JVM implementation and the chosen GC algorithm. I suggest you read the documentation.

提交回复
热议问题