find which type of garbage collector is running

后端 未结 10 921
旧巷少年郎
旧巷少年郎 2020-12-04 08:58

Post JSE 5 ergonomics is intended to automatically select the appropriate type of garbage collector for you (among other things).

I would like to know if there is an

10条回答
  •  不思量自难忘°
    2020-12-04 09:44

    Not a direct answer to your question, but I believe this is what you're looking for.

    According to Java 6 documentation 1 and 2 (not just Java 5):

    Reference 1 says:

    On server-class machines running the server VM, the garbage collector (GC) has changed from the previous serial collector [...] to a parallel collector

    Reference 2 says:

    Starting with J2SE 5.0, when an application starts up, the launcher can attempt to detect whether the application is running on a "server-class" machine and, if so, use the Java HotSpot Server Virtual Machine (server VM) instead of the Java HotSpot Client Virtual Machine (client VM).

    Also, reference 2 says:

    Note: For Java SE 6, the definition of a server-class machine is one with at least 2 CPUs and at least 2GB of physical memory.

    From this information, you can know that if the box is a server (according to 2) then it will be using the parallel GC. You can also infer that it will not change GC during runtime.

    You can probably find the right answer for non-server machines if you dig further into the documentation.

提交回复
热议问题