From 41a8f42a33b30d4cc70dbc8b3499f1403e474855 Mon Sep 17 00:00:00 2001 From: Collin Smith Date: Fri, 23 Jul 2021 19:03:17 -0700 Subject: [PATCH] Fill obtained arrays with null to allow GC --- core/src/main/java/com/riiablo/map2/util/ArrayPool.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/src/main/java/com/riiablo/map2/util/ArrayPool.java b/core/src/main/java/com/riiablo/map2/util/ArrayPool.java index 95033481..2e88adf0 100644 --- a/core/src/main/java/com/riiablo/map2/util/ArrayPool.java +++ b/core/src/main/java/com/riiablo/map2/util/ArrayPool.java @@ -1,6 +1,7 @@ package com.riiablo.map2.util; import java.lang.reflect.Array; +import java.util.Arrays; import org.apache.commons.lang3.builder.ToStringBuilder; import com.badlogic.gdx.utils.Pool; @@ -23,6 +24,11 @@ public class ArrayPool extends Pool { return new ArrayPool<>(clazz, length, initialCapacity, maxCapacity); } + @Override + protected void reset(E object) { + if (object instanceof Object[]) Arrays.fill((Object[]) object, null); + } + final Class clazz; final int length;