Dump memory states to debug OOO

This commit is contained in:
Vitor Pamplona
2023-10-17 18:09:58 -04:00
parent 1e83dbfbe3
commit 2a328ca120
@@ -1,6 +1,7 @@
package com.vitorpamplona.amethyst.ui.navigation
import android.content.Context
import android.os.Debug
import android.util.Log
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
@@ -888,6 +889,17 @@ fun debugState(context: Context) {
NostrUserProfileDataSource.printCounter()
NostrVideoDataSource.printCounter()
val totalMemoryKb = Runtime.getRuntime().totalMemory() / (1024 * 1024)
val freeMemoryKb = Runtime.getRuntime().freeMemory() / (1024 * 1024)
val jvmHeapAllocatedKb = totalMemoryKb - freeMemoryKb
Log.d("STATE DUMP", "Total Heap Allocated: " + jvmHeapAllocatedKb + " MB")
val nativeHeap = Debug.getNativeHeapAllocatedSize() / (1024 * 1024)
Log.d("STATE DUMP", "Total Native Heap Allocated: " + nativeHeap + " MB")
Log.d("STATE DUMP", "Connected Relays: " + RelayPool.connectedRelays())
val imageLoader = Coil.imageLoader(context)