"Jstat -gc <pid>" failed when Windows service for Java process is using domain user

Solution Verified - Updated -

Issue

  • jstat -gc <pid> fails to run, throwing IllegalArgumentException: Could not open PerfMemory, error 2

  • The command psexec.exe -h -s C:\java-11-openjdk-<version>\bin\jstat.exe -gc <PID> throws the following error:

    sun.jvmstat.monitor.MonitorException: <pid> not found
            at jdk.internal.jvmstat/sun.jvmstat.perfdata.monitor.protocol.local.PerfDataBuffer.<init>(PerfDataBuffer.java:84)
            at jdk.internal.jvmstat/sun.jvmstat.perfdata.monitor.protocol.local.LocalMonitoredVm.<init>(LocalMonitoredVm.java:68)
            at jdk.internal.jvmstat/sun.jvmstat.perfdata.monitor.protocol.local.MonitoredHostProvider.getMonitoredVm(MonitoredHostProvider.java:77)
            at jdk.jcmd/sun.tools.jstat.Jstat.logSamples(Jstat.java:107)
            at jdk.jcmd/sun.tools.jstat.Jstat.main(Jstat.java:70)
    Caused by: java.lang.IllegalArgumentException: Could not map vmid to user name
            at java.base/jdk.internal.perf.Perf.attach(Native Method)
            at java.base/jdk.internal.perf.Perf.attachImpl(Perf.java:272)
            at java.base/jdk.internal.perf.Perf.attach(Perf.java:202)
            at jdk.internal.jvmstat/sun.jvmstat.perfdata.monitor.protocol.local.PerfDataBuffer.<init>(PerfDataBuffer.java:64)
            ... 4 more
    

Environment

  • Windows
    • 2012R2, 2019
  • OpenJDK
    • 11
  • Java process running as service
    • domain user/service account is used for the service

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content