aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0347-Set-cap-on-JDK-per-thread-native-byte-buffer-cache.patch
diff options
context:
space:
mode:
authorOwen1212055 <[email protected]>2024-10-23 10:04:01 -0400
committerOwen1212055 <[email protected]>2024-10-23 10:04:01 -0400
commitaf125d26a94147ff40555819d5a9687d24b65d50 (patch)
tree12c00f31e82906203d1d1885b6023f7142f02ed4 /patches/server/0347-Set-cap-on-JDK-per-thread-native-byte-buffer-cache.patch
parentaa37f7250d168e94318e975d3c6d1002e7b82c29 (diff)
downloadPaper-af125d26a94147ff40555819d5a9687d24b65d50.tar.gz
Paper-af125d26a94147ff40555819d5a9687d24b65d50.zip
Patch
Diffstat (limited to 'patches/server/0347-Set-cap-on-JDK-per-thread-native-byte-buffer-cache.patch')
-rw-r--r--patches/server/0347-Set-cap-on-JDK-per-thread-native-byte-buffer-cache.patch30
1 files changed, 30 insertions, 0 deletions
diff --git a/patches/server/0347-Set-cap-on-JDK-per-thread-native-byte-buffer-cache.patch b/patches/server/0347-Set-cap-on-JDK-per-thread-native-byte-buffer-cache.patch
new file mode 100644
index 0000000000..e325a1d810
--- /dev/null
+++ b/patches/server/0347-Set-cap-on-JDK-per-thread-native-byte-buffer-cache.patch
@@ -0,0 +1,30 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Aikar <[email protected]>
+Date: Mon, 4 May 2020 01:08:56 -0400
+Subject: [PATCH] Set cap on JDK per-thread native byte buffer cache
+
+See: https://www.evanjones.ca/java-bytebuffer-leak.html
+
+This is potentially a source of lots of native memory usage.
+
+We are clearly seeing native usage upwards to 1-4GB which doesn't make sense.
+
+Region File usage fixed in previous patch should of tecnically only been somewhat
+temporary until GC finally gets it some time later, but between all the various
+plugins doing IO on various threads, this hidden detail of the JDK could be
+keeping long lived large direct buffers in cache.
+
+Set system properly at server startup if not set already to help protect from this.
+
+diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
+index c618934b5cf66d9625c7be2ac114f1a1ca629d33..124aeebbbae7dc8cea1260bf3134a339c2e152ed 100644
+--- a/src/main/java/org/bukkit/craftbukkit/Main.java
++++ b/src/main/java/org/bukkit/craftbukkit/Main.java
+@@ -27,6 +27,7 @@ public class Main {
+ }
+ // Paper end
+ // Todo: Installation script
++ if (System.getProperty("jdk.nio.maxCachedBufferSize") == null) System.setProperty("jdk.nio.maxCachedBufferSize", "262144"); // Paper - cap per-thread NIO cache size; https://www.evanjones.ca/java-bytebuffer-leak.html
+ OptionParser parser = new OptionParser() {
+ {
+ this.acceptsAll(Main.asList("?", "help"), "Show the help");