jvm 大对象持久存活,不让其进入老年区的方法

[root@ ~]# jmap -heap 20416
Attaching to process ID 20416, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 24.75-b04

using thread-local object allocation.
Parallel GC with 13 thread(s)

Heap Configuration:
   MinHeapFreeRatio = 0
   MaxHeapFreeRatio = 100
   MaxHeapSize      = 17179869184 (16384.0MB)
   NewSize          = 1310720 (1.25MB)
   MaxNewSize       = 8589934592 (8192.0MB)
   OldSize          = 5439488 (5.1875MB)
   NewRatio         = 2
   SurvivorRatio    = 8
   PermSize         = 1073741824 (1024.0MB)
   MaxPermSize      = 2147483648 (2048.0MB)
   G1HeapRegionSize = 0 (0.0MB)

Heap Usage:
PS Young Generation
Eden Space:
   capacity = 8058306560 (7685.0MB)
   used     = 6041346448 (5761.476943969727MB)
   free     = 2016960112 (1923.5230560302734MB)
   74.97042217267048% used
From Space:
   capacity = 257425408 (245.5MB)
   used     = 109640088 (104.5609359741211MB)
   free     = 147785320 (140.9390640258789MB)
   42.591012616749936% used
To Space:
   capacity = 251658240 (240.0MB)
   used     = 0 (0.0MB)
   free     = 251658240 (240.0MB)
   0.0% used
PS Old Generation
   capacity = 8589934592 (8192.0MB)
   used     = 406966904 (388.11388397216797MB)
   free     = 8182967688 (7803.886116027832MB)
   4.7377183102071285% used
PS Perm Generation
   capacity = 1073741824 (1024.0MB)
   used     = 80500800 (76.77154541015625MB)
   free     = 993241024 (947.2284545898438MB)
   7.497221231460571% used

37957 interned Strings occupying 4116240 bytes.

这是 目前 jvm 内存 使用情况

十分钟之后 jvm 内存使用:

[root@ ~]# jmap -heap 20416
Attaching to process ID 20416, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 24.75-b04

using thread-local object allocation.
Parallel GC with 13 thread(s)

Heap Configuration:
   MinHeapFreeRatio = 0
   MaxHeapFreeRatio = 100
   MaxHeapSize      = 17179869184 (16384.0MB)
   NewSize          = 1310720 (1.25MB)
   MaxNewSize       = 8589934592 (8192.0MB)
   OldSize          = 5439488 (5.1875MB)
   NewRatio         = 2
   SurvivorRatio    = 8
   PermSize         = 1073741824 (1024.0MB)
   MaxPermSize      = 2147483648 (2048.0MB)
   G1HeapRegionSize = 0 (0.0MB)

Heap Usage:
PS Young Generation
Eden Space:
   capacity = 8095531008 (7720.5MB)
   used     = 786751672 (750.3048629760742MB)
   free     = 7308779336 (6970.195137023926MB)
   9.718345482495618% used
From Space:
   capacity = 251658240 (240.0MB)
   used     = 101936776 (97.21448516845703MB)
   free     = 149721464 (142.78551483154297MB)
   40.506035486857094% used
To Space:
   capacity = 242745344 (231.5MB)
   used     = 0 (0.0MB)
   free     = 242745344 (231.5MB)
   0.0% used
PS Old Generation
   capacity = 8589934592 (8192.0MB)
   used     = 506258872 (482.8060836791992MB)
   free     = 8083675720 (7709.193916320801MB)
   5.8936289511621% used
PS Perm Generation
   capacity = 1073741824 (1024.0MB)
   used     = 80501720 (76.77242279052734MB)
   free     = 993240104 (947.2275772094727MB)
   7.497306913137436% used

37900 interned Strings occupying 4111744 bytes.

过大的jvm 内存的开销,而且对象的大量存活,不一定就会进入老年区;因为我们可以设置survivor和Eden的大小;以及可以设置threshold的值。threshold设置高一点(比如30),然后Eden设置8G,survivor设置500M.





你可能感兴趣的:(jvm(Hotspot))