From 14aafa1180648e3e2bac2f38dc5934a3e4e49974 Mon Sep 17 00:00:00 2001 From: makamys Date: Tue, 7 Jun 2022 22:05:31 +0200 Subject: Make GC timing frame-based and more evenly distributed --- src/main/java/makamys/lodmod/renderer/GPUMemoryManager.java | 2 +- src/main/java/makamys/lodmod/renderer/LODRenderer.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/main/java/makamys/lodmod/renderer') diff --git a/src/main/java/makamys/lodmod/renderer/GPUMemoryManager.java b/src/main/java/makamys/lodmod/renderer/GPUMemoryManager.java index d8c0c27..d14723d 100644 --- a/src/main/java/makamys/lodmod/renderer/GPUMemoryManager.java +++ b/src/main/java/makamys/lodmod/renderer/GPUMemoryManager.java @@ -42,7 +42,7 @@ public class GPUMemoryManager { Mesh startMesh = null; - while(moved < 5 && checksLeft-- > 0 && !sentMeshes.isEmpty()) { + while(moved < 1 && checksLeft-- > 0 && !sentMeshes.isEmpty()) { if(nextMesh >= sentMeshes.size()) { nextMesh = 0; } diff --git a/src/main/java/makamys/lodmod/renderer/LODRenderer.java b/src/main/java/makamys/lodmod/renderer/LODRenderer.java index 3da4603..5b8e467 100644 --- a/src/main/java/makamys/lodmod/renderer/LODRenderer.java +++ b/src/main/java/makamys/lodmod/renderer/LODRenderer.java @@ -124,10 +124,10 @@ public class LODRenderer { if(LODMod.debugEnabled && Minecraft.getMinecraft().currentScreen == null) { handleKeyboard(); } - if(lastGCTime == -1 || (System.currentTimeMillis() - lastGCTime) > 10) { + if(frameCount % 2 == 0) { mem.runGC(); - lastGCTime = System.currentTimeMillis(); } + lastGCTime = System.currentTimeMillis(); if(lastSaveTime == -1 || (System.currentTimeMillis() - lastSaveTime) > saveInterval && LODMod.saveMeshes) { onSave(); lastSaveTime = System.currentTimeMillis(); -- cgit