private static final Runtime rt = Runtime.getRuntime();
static void gcTillYouDrop() {
rt.gc();
rt.runFinalization();
final CountDownLatch latch = new CountDownLatch(1);
new Object() {
protected void finalize() {
latch.countDown();
}
};
rt.gc();
try {
latch.await();
}
catch(InterruptedException ie){
throw new Error(ie);
}
}
"Hyper-paranoid" indeed, in the words of Kevin.
What I found interesting is that I found this code in sun code benchmarks. (Google for CountdownLatch() gc() )
ReplyDeleteBut it makes a lot of sense in those situations where you want to make sure the garbage collector isn't interfering with the benchmark results.
Thanks for this post!
In this posting know the most important thing, the product provides you with some sort of key phrase loaded web page link an incredible practical web page webpage: matic dapps
ReplyDelete