From e32acbaae7969e0c829b5d730ebf0f2698e69bf5 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Tue, 21 Jul 2020 11:20:15 -0400 Subject: [PATCH] Disable Netty resource leak detector by default. --- .../src/main/java/com/velocitypowered/proxy/Velocity.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/Velocity.java b/proxy/src/main/java/com/velocitypowered/proxy/Velocity.java index 1a7e33c65..6d26f1bfa 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/Velocity.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/Velocity.java @@ -1,5 +1,7 @@ package com.velocitypowered.proxy; +import io.netty.util.ResourceLeakDetector; +import io.netty.util.ResourceLeakDetector.Level; import java.text.DecimalFormat; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -29,6 +31,12 @@ public class Velocity { if (System.getProperty("velocity.natives-tmpdir") != null) { System.setProperty("io.netty.native.workdir", System.getProperty("velocity.natives-tmpdir")); } + + // Disable the resource leak detector by default as it reduces performance. Allow the user to + // override this if desired. + if (System.getProperty("io.netty.leakDetection.level") != null) { + ResourceLeakDetector.setLevel(Level.DISABLED); + } } /**