Fill obtained arrays with null to allow GC

This commit is contained in:
Collin Smith 2021-07-23 19:03:17 -07:00
parent 20b7908efb
commit 41a8f42a33

View File

@ -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<E> extends Pool<E> {
return new ArrayPool<>(clazz, length, initialCapacity, maxCapacity);
}
@Override
protected void reset(E object) {
if (object instanceof Object[]) Arrays.fill((Object[]) object, null);
}
final Class<E> clazz;
final int length;