<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hi, <div><br></div><div>I was looking at G1 code and found this.</div><div><br></div><div><div style="font-family: Menlo; font-size: 11px; margin: 0px;">jlong G1CollectedHeap::millis_since_last_gc() {</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; color: rgb(0, 132, 0);"><span style="color: rgb(0, 0, 0);"> </span>// assert(false, "NYI");</div><div style="font-family: Menlo; font-size: 11px; margin: 0px;"> return <span style="color: rgb(39, 42, 216);">0</span>;</div><div style="font-family: Menlo; font-size: 11px; margin: 0px;">}</div></div><div style="font-family: Menlo; font-size: 11px; margin: 0px;"><br></div><div style="font-family: Menlo; font-size: 11px; margin: 0px;">As long as this method returns 0, this code in sun.misc.GC always fails as maxObjectInspectionAge() is a native call that tunnels back to millis_since_last_gc().</div><div style="font-family: Menlo; font-size: 11px; margin: 0px;"><br></div><div style="font-family: Menlo; font-size: 11px; margin: 0px;"><div style="margin: 0px;"> <span style="color: #bb2ca2">public</span> <span style="color: #bb2ca2">void</span> run() {</div><div style="margin: 0px;"> <span style="color: #bb2ca2">for</span> (;;) {</div><div style="margin: 0px;"> <span style="color: #bb2ca2">long</span> l;</div><div style="margin: 0px;"> <span style="color: #bb2ca2">synchronized</span> (lock) {</div><div style="margin: 0px; min-height: 13px;"><br></div><div style="margin: 0px;"> l = latencyTarget;</div><div style="margin: 0px;"> <span style="color: #bb2ca2">if</span> (l == NO_TARGET) {</div><div style="margin: 0px; color: rgb(0, 132, 0);"><span style="color: #000000"> </span>/* No latency target, so exit */</div><div style="margin: 0px;"> GC.daemon = <span style="color: #bb2ca2">null</span>;</div><div style="margin: 0px;"> <span style="color: #bb2ca2">return</span>;</div><div style="margin: 0px;"> }</div><div style="margin: 0px; min-height: 13px;"><br></div><div style="margin: 0px;"> <span style="color: #bb2ca2">long</span> d = maxObjectInspectionAge();</div><div style="margin: 0px;"> <span style="color: #bb2ca2">if</span> (d >= l) {</div><div style="margin: 0px; color: rgb(0, 132, 0);"><span style="color: #000000"> </span>/* Do a full collection. There is a remote possibility</div><div style="margin: 0px; color: rgb(0, 132, 0);"> * that a full collection will occurr between the time</div><div style="margin: 0px; color: rgb(0, 132, 0);"> * we sample the inspection age and the time the GC</div><div style="margin: 0px; color: rgb(0, 132, 0);"> * actually starts, but this is sufficiently unlikely</div><div style="margin: 0px; color: rgb(0, 132, 0);"> * that it doesn't seem worth the more expensive JVM</div><div style="margin: 0px; color: rgb(0, 132, 0);"> * interface that would be required.</div><div style="margin: 0px; color: rgb(0, 132, 0);"> */</div><div style="margin: 0px;"> System.gc();</div><div style="margin: 0px;"> d = <span style="color: #272ad8">0</span>;</div><div style="margin: 0px;"> }</div><div style="margin: 0px; min-height: 13px;"><br></div><div style="margin: 0px; color: rgb(0, 132, 0);"><span style="color: #000000"> </span>/* Wait for the latency period to expire,</div><div style="margin: 0px; color: rgb(0, 132, 0);"> * or for notification that the period has changed</div><div style="margin: 0px; color: rgb(0, 132, 0);"> */</div><div style="margin: 0px;"> <span style="color: #bb2ca2">try</span> {</div><div style="margin: 0px;"> lock.wait(l - d);</div><div style="margin: 0px;"> } <span style="color: #bb2ca2">catch</span> (InterruptedException x) {</div><div style="margin: 0px;"> <span style="color: #bb2ca2">continue</span>;</div><div style="margin: 0px;"> }</div><div style="margin: 0px;"> }</div><div style="margin: 0px;"> }</div><div style="margin: 0px;"> }</div><div style="margin: 0px;"><br></div><div style="margin: 0px;">My guess is; this is intentional?</div><div style="margin: 0px;"><br></div><div style="margin: 0px;">Kind regards,</div><div style="margin: 0px;">Kirk Pepperdine</div><div style="margin: 0px;"><br></div></div></body></html>