Skip to content

Commit

Permalink
8325496: Make TrimNativeHeapInterval a product switch
Browse files Browse the repository at this point in the history
Reviewed-by: lucy
Backport-of: 4296ddfc6336f062e92fdfdc3b41ca20da26a126
  • Loading branch information
MBaesken committed Feb 29, 2024
1 parent 5687c5a commit 2b34eeb
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/hotspot/share/runtime/globals.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -2097,7 +2097,7 @@ const intx ObjectAlignmentInBytes = 8;
develop(bool, TraceOptimizedUpcallStubs, false, \
"Trace optimized upcall stub generation") \
\
product(uint, TrimNativeHeapInterval, 0, EXPERIMENTAL, \
product(uint, TrimNativeHeapInterval, 0, \
"Interval, in ms, at which the JVM will trim the native heap if " \
"the platform supports that. Lower values will reclaim memory " \
"more eagerly at the cost of higher overhead. A value of 0 " \
Expand Down
13 changes: 12 additions & 1 deletion src/java.base/share/man/java.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.\" Copyright (c) 1994, 2022, Oracle and/or its affiliates. All rights reserved.
.\" Copyright (c) 1994, 2024, Oracle and/or its affiliates. All rights reserved.
.\" DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
.\"
.\" This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -1540,6 +1540,17 @@ and its committed regions.
.RE
.RE
.TP
.B \f[CB]-XX:TrimNativeHeapInterval=\f[R]\f[I]millis\f[R]
Interval, in ms, at which the JVM will trim the native heap.
Lower values will reclaim memory more eagerly at the cost of higher
overhead.
A value of 0 (default) disables native heap trimming.
Native heap trimming is performed in a dedicated thread.
.RS
.PP
This option is only supported on Linux with GNU C Library (glibc).
.RE
.TP
.B \f[CB]\-XX:ObjectAlignmentInBytes=\f[R]\f[I]alignment\f[R]
Sets the memory alignment of Java objects (in bytes).
By default, the value is set to 8 bytes.
Expand Down
6 changes: 3 additions & 3 deletions test/hotspot/jtreg/gtest/NativeHeapTrimmerGtest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023 Red Hat, Inc. All rights reserved.
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2024, Red Hat, Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -28,5 +28,5 @@
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.xml
* @run main/native GTestWrapper --gtest_filter=os.trim* -Xlog:trimnative -XX:+UnlockExperimentalVMOptions -XX:TrimNativeHeapInterval=100
* @run main/native GTestWrapper --gtest_filter=os.trim* -Xlog:trimnative -XX:TrimNativeHeapInterval=100
*/
14 changes: 7 additions & 7 deletions test/hotspot/jtreg/runtime/os/TestTrimNative.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Copyright (c) 2023 SAP SE. All rights reserved.
* Copyright (c) 2023 Red Hat, Inc. All rights reserved.
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2024, Red Hat, Inc. All rights reserved.
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -270,7 +270,7 @@ public static void main(String[] args) throws Exception {
long trimInterval = 500; // twice per second
long ms1 = System.currentTimeMillis();
OutputAnalyzer output = runTestWithOptions(
new String[] { "-XX:+UnlockExperimentalVMOptions", "-XX:TrimNativeHeapInterval=" + trimInterval },
new String[] { "-XX:TrimNativeHeapInterval=" + trimInterval },
new String[] { TestTrimNative.Tester.class.getName(), "5000" }
);
long ms2 = System.currentTimeMillis();
Expand All @@ -285,7 +285,7 @@ public static void main(String[] args) throws Exception {

case "trimNativeHighInterval": {
OutputAnalyzer output = runTestWithOptions(
new String[] { "-XX:+UnlockExperimentalVMOptions", "-XX:TrimNativeHeapInterval=" + Integer.MAX_VALUE },
new String[] { "-XX:TrimNativeHeapInterval=" + Integer.MAX_VALUE },
new String[] { TestTrimNative.Tester.class.getName(), "5000" }
);
checkExpectedLogMessages(output, true, Integer.MAX_VALUE);
Expand All @@ -297,7 +297,7 @@ public static void main(String[] args) throws Exception {
case "trimNativeLowIntervalStrict": {
long ms1 = System.currentTimeMillis();
OutputAnalyzer output = runTestWithOptions(
new String[] { "-XX:+UnlockExperimentalVMOptions", "-XX:TrimNativeHeapInterval=1" },
new String[] { "-XX:TrimNativeHeapInterval=1" },
new String[] { TestTrimNative.Tester.class.getName(), "0" }
);
long ms2 = System.currentTimeMillis();
Expand All @@ -308,7 +308,7 @@ public static void main(String[] args) throws Exception {

case "testOffOnNonCompliantPlatforms": {
OutputAnalyzer output = runTestWithOptions(
new String[] { "-XX:+UnlockExperimentalVMOptions", "-XX:TrimNativeHeapInterval=1" },
new String[] { "-XX:TrimNativeHeapInterval=1" },
new String[] { "-version" }
);
checkExpectedLogMessages(output, false, 0);
Expand All @@ -319,7 +319,7 @@ public static void main(String[] args) throws Exception {

case "testOffExplicit": {
OutputAnalyzer output = runTestWithOptions(
new String[] { "-XX:+UnlockExperimentalVMOptions", "-XX:TrimNativeHeapInterval=0" },
new String[] { "-XX:TrimNativeHeapInterval=0" },
new String[] { "-version" }
);
checkExpectedLogMessages(output, false, 0);
Expand Down

1 comment on commit 2b34eeb

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.