forked from hpfxd/PandaSpigot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0021-Set-cap-on-JDK-per-thread-native-byte-buffer-cache.patch
30 lines (23 loc) · 1.49 KB
/
0021-Set-cap-on-JDK-per-thread-native-byte-buffer-cache.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <[email protected]>
Date: Sun, 31 Oct 2021 09:46:32 -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 fc6061a800b6e8a61eda70aadc6abb3627805916..715fb447a1428953d7e1425cb12a5e8dcff574e8 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -18,6 +18,7 @@ public class Main {
public static void main(String[] args) {
// Todo: Installation script
+ if (System.getProperty("jdk.nio.maxCachedBufferSize") == null) System.setProperty("jdk.nio.maxCachedBufferSize", "262144"); // PandaSpigot - cap per-thread NIO cache size
OptionParser parser = new OptionParser() {
{
acceptsAll(asList("?", "help"), "Show the help");