diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/client/StarboundClient.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/client/StarboundClient.kt index 4db0a9e0..b5d07af1 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/client/StarboundClient.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/client/StarboundClient.kt @@ -363,7 +363,7 @@ class StarboundClient(val starbound: Starbound) : Closeable { return true } - val measure = GLFW.glfwGetTime() + val measure = JVMTimeSource.INSTANCE.seconds if (frameRenderTime != 0.0 && starbound.initialized) world?.think(frameRenderTime) @@ -438,11 +438,11 @@ class StarboundClient(val starbound: Starbound) : Closeable { GLFW.glfwPollEvents() input.think() - camera.think(GLFW.glfwGetTime() - measure) + camera.think(JVMTimeSource.INSTANCE.seconds - measure) gl.cleanup() - frameRenderTime = GLFW.glfwGetTime() - measure + frameRenderTime = JVMTimeSource.INSTANCE.seconds - measure frameRenderTimes[++frameRenderIndex % frameRenderTimes.size] = frameRenderTime return true diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/client/gl/GLStateTracker.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/client/gl/GLStateTracker.kt index 5e3e4677..571126cc 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/client/gl/GLStateTracker.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/client/gl/GLStateTracker.kt @@ -25,6 +25,7 @@ import java.io.File import java.io.FileNotFoundException import java.lang.ref.Cleaner import java.util.concurrent.ThreadFactory +import java.util.concurrent.atomic.AtomicLong import kotlin.collections.ArrayList import kotlin.collections.HashMap import kotlin.properties.ReadWriteProperty @@ -151,7 +152,12 @@ class GLStateTracker(val locator: ISBFileLocator) { private val cleanerBacklog = ArrayList<() -> Unit>() - var objectsCleaned = 0 + @Volatile + var objectsCleaned = 0L + private set + + @Volatile + var gcHits = 0L private set private val cleaner = Cleaner.create(object : ThreadFactory { @@ -170,6 +176,8 @@ class GLStateTracker(val locator: ISBFileLocator) { fn(nativeRef) checkForGLError() } else { + gcHits++ + synchronized(cleanerBacklog) { cleanerBacklog.add { fn(nativeRef)