From 0db099de9aaa00a92448d73a545aa21181096750 Mon Sep 17 00:00:00 2001 From: Ralf Schmelter Date: Sat, 23 Sep 2023 20:07:57 +0200 Subject: [PATCH] Make sure we only need one env var --- src/hotspot/os/posix/malloctrace/mallocTrace2.cpp | 6 +++--- src/hotspot/share/runtime/globals.hpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hotspot/os/posix/malloctrace/mallocTrace2.cpp b/src/hotspot/os/posix/malloctrace/mallocTrace2.cpp index d0719df0dcc..b1dd80264aa 100644 --- a/src/hotspot/os/posix/malloctrace/mallocTrace2.cpp +++ b/src/hotspot/os/posix/malloctrace/mallocTrace2.cpp @@ -1655,9 +1655,10 @@ void MallocStatistic::initialize() { mallocStatImpl::MallocStatisticImpl::initialize(); + bool dump_via_env = DEBUG_ONLY(::getenv("MALLOC_TRACE_TEST_DUMP") != NULL) NOT_DEBUG(false); bool start_via_env = DEBUG_ONLY(::getenv("MALLOC_TRACE_AT_STARTUP") != NULL) NOT_DEBUG(false); - if (start_via_env || MallocTraceAtStartup) { + if (start_via_env || dump_via_env || MallocTraceAtStartup) { TraceSpec spec; stringStream ss; @@ -1669,13 +1670,12 @@ void MallocStatistic::initialize() { // Don't fail when enabled via environment, since we use this // when we have no real control over the started VM. - if (!enable(&ss, spec) && !start_via_env && MallocTraceExitIfFail) { + if (!enable(&ss, spec) && !start_via_env && !dump_via_env && MallocTraceExitIfFail) { fprintf(stderr, "%s", ss.base()); os::exit(1); } } - bool dump_via_env = DEBUG_ONLY(::getenv("MALLOC_TRACE_TEST_DUMP") != NULL) NOT_DEBUG(false); if (dump_via_env || MallocTraceTestDump) { char const* file = dump_via_env ? ::getenv("MALLOC_TRACE_TEST_DUMP") : MallocTraceTestDumpOutput; diff --git a/src/hotspot/share/runtime/globals.hpp b/src/hotspot/share/runtime/globals.hpp index 3e5dc3bc58f..01c9852e1cf 100644 --- a/src/hotspot/share/runtime/globals.hpp +++ b/src/hotspot/share/runtime/globals.hpp @@ -590,7 +590,7 @@ const int ObjectAlignmentInBytes = 8; "If enabled we do a dump of the malloc trace in regular " \ "intervals.") \ \ - product(uintx, MallocTraceTestDumpInterval, 60, \ + product(uintx, MallocTraceTestDumpInterval, 10, \ "The interval in seconds for the test dump.") \ \ product(ccstr, MallocTraceTestDumpSort, "", \