Artur Linhart created DAEMON-412:
------------------------------------

             Summary: Tomcat started as windows service does not support Java 
Native Memory Tracking feature because of improper JVM initialization by Procrun
                 Key: DAEMON-412
                 URL: https://issues.apache.org/jira/browse/DAEMON-412
             Project: Commons Daemon
          Issue Type: Bug
          Components: Procrun
         Environment: Windows
            Reporter: Artur Linhart


In the case the user specifies some from the the NativeMemoryTracking 
parameters (see 
[https://docs.oracle.com/en/java/javase/11/vm/native-memory-tracking.html#GUID-0DB3B8D1-8D7D-447F-B6FF-15620103EE47
 
|https://docs.oracle.com/en/java/javase/11/vm/native-memory-tracking.html#GUID-0DB3B8D1-8D7D-447F-B6FF-15620103EE47]
) like 

-XX:NativeMemoryTracking=summary

in Windows service registry, restarts the service, so the option can be seen in 
the log file by the startup options, then the Native memory tracking is still 
disabled and does not work. If you try with

jcmd <pid> VM.native_memory summary

to get the information about the native JVM memory in the tomcats JVM, the jcmd 
call fails with the message

<pid>:
Native memory tracking is not enabled

and in the Tomcat's log file can be found following error message:

Java HotSpot(TM) 64-Bit Server VM warning: Native Memory Tracking did not setup 
properly, using wrong launcher? 

The problem seems to be in the JVM launcher Procrun, which dies not initialize 
the JVM properly - as far as I have understood from this blog: 
[https://blogs.oracle.com/poonam/using-nmt-with-custom-jvm-launcher 
|https://blogs.oracle.com/poonam/using-nmt-with-custom-jvm-launcher]
The Procrun.exe has to define some environment variable before the start of 
JVM, etc. to get the native memory tracking to work.

Known workaround is the start of Tomcat from the command line, but this is no 
option in the productive environment, where you have to let the service run for 
longer time to collect the proper result and maybe also as some different user 
because of security concerns, then such option is simply out of possible 
scenarios. So the Tomcat service JVM cannot be in such circumstances tracked by 
NMT at all, what is the problem in the mission-critical applications.

The Procrun should be modified in the way it enables the NMT in the windows 
service by the startup, by setting the environment variable 
NMT_LEVEL_<pid> to the value "detail" or "summary" (or "off" if unspecified) in 
the dependency on the specified or unspecified option of 
-XX:NativeMemoryTracking
like done normally by java.exe
Remark: Also change of the startup mode from "jvm" to "exe" or "java" does not 
help,. then the windows service does not start at all.

See also the Tomcat bug 
[https://bz.apache.org/bugzilla/show_bug.cgi?id=63922|https://bz.apache.org/bugzilla/show_bug.cgi?id=63922]
which has been qualified as invalid because the problem seems to be in is in 
PROCRUN.

See also the bug [TOMEE-2738]




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to