This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-daemon.git
The following commit(s) were added to refs/heads/master by this push: new e7ab360 Fix DAEMON-412 for unix - Add NMT support e7ab360 is described below commit e7ab36080a6399a35c477c7d33246e5ca31eb44a Author: Mark Thomas <ma...@apache.org> AuthorDate: Mon Aug 24 22:06:56 2020 +0100 Fix DAEMON-412 for unix - Add NMT support https://issues.apache.org/jira/projects/DAEMON/issues/DAEMON-412 --- src/changes/changes.xml | 5 ++++- src/native/unix/native/java.c | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 2429cf9..8c9a3e2 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -51,7 +51,7 @@ path used by OpenJDK 11. </action> <action type="add" dev="markt"> - procrun. Add additional debug logging for Java start mode. + Procrun. Add additional debug logging for Java start mode. </action> <action type="fix" dev="markt" due-to="Ray Wang"> jsvc. Remove incorrect definition 'supported_os' which defined in @@ -64,6 +64,9 @@ <action issue="DAEMON-419" type="add" dev="ggregory" due-to="mads1980"> Update arguments.c to support Java 11 --enable-preview #18. </action> + <action issue="DAEMON-412" type="add" dev="markt"> + jsvc and Procrun. Add support for Java native memory tracking. + </action> </release> <release version="1.2.2" date="2019-10-04" description="Bug fix release"> <action issue="DAEMON-408" type="fix" dev="markt"> diff --git a/src/native/unix/native/java.c b/src/native/unix/native/java.c index 45dcf8e..b69d5c6 100644 --- a/src/native/unix/native/java.c +++ b/src/native/unix/native/java.c @@ -158,6 +158,22 @@ bool java_init(arg_data *args, home_data *data) return false; } + /* Some Java options require environment variables to be set before loading + * Java when using JNI + */ + for (x = 0; x < args->onum; x++) { + if (!strncmp(args->opts[x], "-XX:NativeMemoryTracking=", 25)) { + fprintf(stdout, "Found [%s]\n", args->opts[x]); + char *value = args->opts[x] + 25; + fprintf(stdout, "Found value [%s]\n", value); + if (strcmp(value, "off")) { + snprintf(daemonprocid, sizeof(daemonprocid), "NMT_LEVEL_%d=%s", (int)getpid(), value); + fprintf(stdout, "Setting environment entry [%s]\n", daemonprocid); + putenv(daemonprocid); + } + } + } + /* Initialize the DSO library */ if (dso_init() != true) { log_error("Cannot initialize the dynamic library loader");