0

Our application(-Xms=8GB, -Xmx=8GB) is running on the oracle Java 1.8. If the application uses RMI, Distributed GC(System.gc()) is supposed to be invoked every hour by default.

https://docs.oracle.com/javase/9/gctuning/JSGCT.pdf, under page 11-

Explicit Garbage Collection" for its full details. “One of the most commonly encountered uses of explicit garbage collection occurs with the distributed garbage collection (DGC) of Remote Method Invocation (RMI). Applications using RMI refer to objects in other virtual machines. Garbage cannot be collected in these distributed applications without occasionally invoking garbage collection of the local heap, so RMI forces full collections periodically

However, it sometimes does not work after restarting. Actually, the behavior is unpredictable.

If DGC is invoked when the application starts up, it is invoked every hour permanently. But if it isn’t, it is never invoked. When DGC isn’t invoked periodically, heap usage keeps increasing until JVM determines that it’s time to call a full GC(Ergonomics). And it also causes long pause time. (10~20 seconds)

On the other hand, periodic DGC(System.gc())’s pause time is 1~2 seconds.

[Ergonomics GC when System.gc() wasn’t invoked periodically.]

2019-05-03T07:03:17.659+0900: 6491382.829: [Full GC (Ergonomics) 
[PSYoungGen: 574976K->147272K(2036224K)] 
[ParOldGen: 5569798K->5592083K(5592576K)] 6144774K->5739356K(7628800K), 
[Metaspace: 173381K->173381K(1212416K)], 18.3845440 secs] 
[Times: user=34.28 sys=0.00, real=18.39 secs]

2019-05-03T07:04:21.178+0900: 6491446.349: [Full GC (Ergonomics) [
PSYoungGen: 1488200K->0K(2036224K)] 
[ParOldGen: 5592083K->5085211K(5592576K)] 7080284K->5085211K(7628800K), 
[Metaspace: 173381K->173381K(1212416K)], 10.7514387 secs] 
[Times: user=20.69 sys=0.00, real=10.75 secs] 

[System.gc() by DGC]

2019-08-13T14:40:30.186+0900: 93664.100: [GC (System.gc()) [PSYoungGen: 208863K->1792K(346112K)] 958151K->751079K(1567744K), 0.0078939 secs] 
[Times: user=0.02 sys=0.00, real=0.01 secs] 

2019-08-13T14:40:30.194+0900: 93664.108: [Full GC (System.gc()) [PSYoungGen: 1792K->0K(346112K)] 
[ParOldGen: 749287K->749172K(1221632K)] 751079K->749172K(1567744K), 
[Metaspace: 139206K->139206K(1179648K)], 2.0667289 secs] 
[Times: user=10.53 sys=1.64, real=2.07 secs]

Here are my questions.

  1. Can anybody explain why System.gc() by DGC isn’t sometimes invoked?

  2. Is there any JVM option to trigger DGC forcibly? I tried to give GC interval option explicitly as shown below, but it didn’t work.

    -Dsun.rmi.dgc.client.gcInterval=3600000

    -Dsun.rmi.dgc.server.gcInterval=3600000

Please advise.

Thanks and regards, SJ

char
  • 2,063
  • 3
  • 15
  • 26
SJ Yim
  • 1
  • The document is incorrect: ' RMI forces full collections periodically.' What it does is call `System.gc()` hourly. As per the Javadoc, this is only a hint that the JVM can act on or ignore. There is no way to *force* GC. – user207421 Aug 21 '19 at 00:03
  • @user207421, Thanks for your comment. I know System.gc() does not guarantee that JVM will start GC immediately. And I agree that ' RMI forces full collections periodically.' is incorrect since System.gc() just requests JVM to perform GC. However, I still wonder why DGC(by RMI) sometimes invoked and sometimes not. – SJ Yim Aug 22 '19 at 01:39
  • Last time I looked (which is admittedly some years ago, but the RMI codebase is very stable and practically untouched for decades) RMI scheduled a `System.gc()` call once an hour. If it doesn't do that I can't explain it. – user207421 Aug 29 '19 at 02:10
  • @user207421 I see. Thanks for your comment. – SJ Yim Sep 04 '19 at 02:12

0 Answers0