mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
e7f3ca4505
Allows us much greater control over the Spigot portion of the code and makes us more "proper" Credit to @Dmck2b for originally passing the idea along a while back
60 lines
No EOL
2.5 KiB
Diff
60 lines
No EOL
2.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: md_5 <git@md-5.net>
|
|
Date: Fri, 20 Jun 2014 19:40:00 +1000
|
|
Subject: [PATCH] Prevent Unbounded IntCache Growth
|
|
|
|
Based on work by Peter Lawrey, this commit prevents unbounded growth of the integer cache and instead caps it to a value specified in the configuration (1024 by default). Should prevent thrashing, especially around world generation.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/IntCache.java b/src/main/java/net/minecraft/server/IntCache.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/server/IntCache.java
|
|
+++ b/src/main/java/net/minecraft/server/IntCache.java
|
|
@@ -0,0 +0,0 @@ public class IntCache {
|
|
if (i <= 256) {
|
|
if (b.isEmpty()) {
|
|
aint = new int[256];
|
|
- c.add(aint);
|
|
+ if (c.size() < org.spigotmc.SpigotConfig.intCacheLimit) c.add(aint);
|
|
return aint;
|
|
} else {
|
|
aint = (int[]) b.remove(b.size() - 1);
|
|
- c.add(aint);
|
|
+ if (c.size() < org.spigotmc.SpigotConfig.intCacheLimit) c.add(aint);
|
|
return aint;
|
|
}
|
|
} else if (i > a) {
|
|
@@ -0,0 +0,0 @@ public class IntCache {
|
|
d.clear();
|
|
e.clear();
|
|
aint = new int[a];
|
|
- e.add(aint);
|
|
+ if (e.size() < org.spigotmc.SpigotConfig.intCacheLimit) e.add(aint);
|
|
return aint;
|
|
} else if (d.isEmpty()) {
|
|
aint = new int[a];
|
|
- e.add(aint);
|
|
+ if (e.size() < org.spigotmc.SpigotConfig.intCacheLimit) e.add(aint);
|
|
return aint;
|
|
} else {
|
|
aint = (int[]) d.remove(d.size() - 1);
|
|
- e.add(aint);
|
|
+ if (e.size() < org.spigotmc.SpigotConfig.intCacheLimit) e.add(aint);
|
|
return aint;
|
|
}
|
|
}
|
|
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/org/spigotmc/SpigotConfig.java
|
|
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
|
|
@@ -0,0 +0,0 @@ public class SpigotConfig
|
|
{
|
|
saveUserCacheOnStopOnly = getBoolean( "settings.save-user-cache-on-stop-only", false );
|
|
}
|
|
+
|
|
+ public static int intCacheLimit;
|
|
+ private static void intCacheLimit()
|
|
+ {
|
|
+ intCacheLimit = getInt( "settings.int-cache-limit", 1024 );
|
|
+ }
|
|
}
|
|
--
|