From 66390223c61d2a9d280b40384c79fa29302bd5c5 Mon Sep 17 00:00:00 2001 From: Brettflan Date: Mon, 20 Jan 2014 12:51:44 -0600 Subject: [PATCH] Added config option "fill-memory-tolerance" which defaults to 500. If/when the Fill process pauses due to low memory (<200 MB), this setting is the amount of free memory (in MB) required to be available before it automatically continues. This option isn't made available to change through a command as most people shouldn't change it. It's been made available for people who are running extremely low memory (and thus necessarily tiny) servers which have less than 768 MB memory available to their CraftBukkit server. --- src/main/java/com/wimbli/WorldBorder/Config.java | 8 ++++++++ src/main/java/com/wimbli/WorldBorder/WorldFillTask.java | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/wimbli/WorldBorder/Config.java b/src/main/java/com/wimbli/WorldBorder/Config.java index 1458f76..82cd8d4 100644 --- a/src/main/java/com/wimbli/WorldBorder/Config.java +++ b/src/main/java/com/wimbli/WorldBorder/Config.java @@ -51,6 +51,7 @@ public class Config private static boolean killPlayer = false; private static boolean denyEnderpearl = false; private static int fillAutosaveFrequency = 30; + private static int fillMemoryTolerance = 500; // for monitoring plugin efficiency // public static long timeUsed = 0; @@ -453,6 +454,11 @@ public class Config return (int)((rt.maxMemory() - rt.totalMemory() + rt.freeMemory()) / 1048576); // 1024*1024 = 1048576 (bytes in 1 MB) } + public static boolean AvailableMemoryTooLow() + { + return AvailableMemory() < fillMemoryTolerance; + } + public static boolean HasPermission(Player player, String request) { @@ -529,6 +535,7 @@ public class Config denyEnderpearl = cfg.getBoolean("deny-enderpearl", false); fillAutosaveFrequency = cfg.getInt("fill-autosave-frequency", 30); bypassPlayers = Collections.synchronizedSet(new LinkedHashSet(cfg.getStringList("bypass-list"))); + fillMemoryTolerance = cfg.getInt("fill-memory-tolerance", 500); StartBorderTimer(); @@ -626,6 +633,7 @@ public class Config cfg.set("deny-enderpearl", denyEnderpearl); cfg.set("fill-autosave-frequency", fillAutosaveFrequency); cfg.set("bypass-list", new ArrayList(bypassPlayers)); + cfg.set("fill-memory-tolerance", fillMemoryTolerance); cfg.set("worlds", null); Iterator world = borders.entrySet().iterator(); diff --git a/src/main/java/com/wimbli/WorldBorder/WorldFillTask.java b/src/main/java/com/wimbli/WorldBorder/WorldFillTask.java index 4176b12..f06abe0 100644 --- a/src/main/java/com/wimbli/WorldBorder/WorldFillTask.java +++ b/src/main/java/com/wimbli/WorldBorder/WorldFillTask.java @@ -140,7 +140,7 @@ public class WorldFillTask implements Runnable if (pausedForMemory) { // if available memory gets too low, we automatically pause, so handle that - if (Config.AvailableMemory() < 500) + if (Config.AvailableMemoryTooLow()) return; pausedForMemory = false;