Slide 29
Slide 29 text
totalFreeMemoryで
残りのメモリを数値化したい
private const val MEGA_BYTE = 1048576 // 1024 * 1024
@JvmStatic
fun printCurrentApplicationVMMemory() {
val runtimeVersion = System.getProperty("java.vm.version")
val runtime = Runtime.getRuntime()
val maxMemory = runtime.maxMemory() / MEGA_BYTE
val freeMemory = runtime.freeMemory() / MEGA_BYTE
val totalMemory = runtime.totalMemory() / MEGA_BYTE
val totalFreeMemory = maxMemory - totalMemory + freeMemory
Timber.d(
"#Memory CurrentApplicationVMMemory(MB) %s, %s, %s, %s, %s",
" totalFreeMemory: $totalFreeMemory",
" runtimeVersion: $runtimeVersion",
" maxMemory: $maxMemory",
" freeMemory: $freeMemory",
" totalMemory: $totalMemory",
)
}
MemoryUtil