RuntimeMXBean.getName() hangs on Mac OS X Sierra - how to fix?

Question

If I run the following on OS X Sierra (JDK 8u111), it takes 5 seconds to run (as opposed to milliseconds on e.g. Linux):

import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;

public class BeanTest {
    public static void main (String[] args) {
        RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean();
        System.out.println(bean.getName());
    }
}

This is causing a massive slowdown of a library that I use, whose newer versions call this bit of the management API. My first thought is that it's a DNS issue (the computer is on a local home NAT) but my attempt to resolve either my local hostname or my local IP address in the shell returns an (NXDOMAIN) answer instantly. Running dtruss on the Java process produced constant repetition of these lines for the duration of the 5 second lag:

  782/0x36f5:  psynch_cvwait(0x7FEE4170B968, 0x20100000300, 0x200)       = -1 Err#316
  782/0x36f5:  gettimeofday(0x7000039B4938, 0x0, 0x0)        = 0 0

What is going on here and what can I do to unblock this bottleneck?


Show source
| java   | osx   | java.lang   2017-01-06 19:01 0 Answers

Answers ( 0 )

◀ Go back