mirror of
https://github.com/FabricMC/fabric.git
synced 2025-04-11 22:45:38 -04:00
Fix memory leak by using weak set for ArrayBackedEvent list (#2848)
* use weak set for array backed events list * use thread safe map
This commit is contained in:
parent
eff3bcb77a
commit
70be179cf3
1 changed files with 6 additions and 3 deletions
|
@ -23,16 +23,19 @@ import java.lang.reflect.Array;
|
|||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.google.common.collect.MapMaker;
|
||||
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import net.fabricmc.fabric.api.event.Event;
|
||||
|
||||
public final class EventFactoryImpl {
|
||||
private static final List<ArrayBackedEvent<?>> ARRAY_BACKED_EVENTS = new ArrayList<>();
|
||||
private static final Set<ArrayBackedEvent<?>> ARRAY_BACKED_EVENTS
|
||||
= Collections.newSetFromMap(new MapMaker().weakKeys().makeMap());
|
||||
|
||||
private EventFactoryImpl() { }
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue