mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-19 14:59:25 +00:00
30 lines
1.7 KiB
Diff
30 lines
1.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
|
Date: Sat, 10 Jun 2023 13:06:44 +0300
|
|
Subject: [PATCH] Fix memory leak
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/biome/Biome.java b/src/main/java/net/minecraft/world/level/biome/Biome.java
|
|
index 65012a12e1430956ef55ced56773e6354ac26444..2bcd3ee3bbdf246ef429a8310ca96ba3fb4afd2c 100644
|
|
--- a/src/main/java/net/minecraft/world/level/biome/Biome.java
|
|
+++ b/src/main/java/net/minecraft/world/level/biome/Biome.java
|
|
@@ -66,7 +66,8 @@ public final class Biome {
|
|
private final BiomeGenerationSettings generationSettings;
|
|
private final MobSpawnSettings mobSettings;
|
|
private final BiomeSpecialEffects specialEffects;
|
|
- private final ThreadLocal<Long2FloatLinkedOpenHashMap> temperatureCache = ThreadLocal.withInitial(() -> {
|
|
+ private static final ThreadLocal<Long2FloatLinkedOpenHashMap> temperatureCache = ThreadLocal.withInitial(() -> { // DivineMC - fix memory leak
|
|
+
|
|
return Util.make(() -> {
|
|
Long2FloatLinkedOpenHashMap long2FloatLinkedOpenHashMap = new Long2FloatLinkedOpenHashMap(1024, 0.25F) {
|
|
protected void rehash(int i) {
|
|
@@ -118,7 +119,7 @@ public final class Biome {
|
|
@Deprecated
|
|
public float getTemperature(BlockPos blockPos) {
|
|
long l = blockPos.asLong();
|
|
- Long2FloatLinkedOpenHashMap long2FloatLinkedOpenHashMap = this.temperatureCache.get();
|
|
+ Long2FloatLinkedOpenHashMap long2FloatLinkedOpenHashMap = temperatureCache.get(); // DivineMC - fix memory leak
|
|
float f = long2FloatLinkedOpenHashMap.get(l);
|
|
if (!Float.isNaN(f)) {
|
|
return f;
|