File tree Expand file tree Collapse file tree 4 files changed +55
-82
lines changed
java/ch/bailu/aat_gtk/lib Expand file tree Collapse file tree 4 files changed +55
-82
lines changed Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ package ch.bailu.aat_gtk.app
22
33import ch.bailu.aat_gtk.config.Environment
44import ch.bailu.aat_gtk.config.Strings
5- import ch.bailu.aat_gtk.lib.GResource
65import ch.bailu.aat_gtk.lib.RuntimeInfo
76import ch.bailu.aat_gtk.preferences.GtkStorage
87import ch.bailu.aat_gtk.preferences.PreferenceLoadDefaults
@@ -17,6 +16,7 @@ import ch.bailu.aat_lib.logger.BroadcastLoggerFactory
1716import ch.bailu.aat_lib.logger.PrintLnLoggerFactory
1817import ch.bailu.gtk.adw.Application
1918import ch.bailu.gtk.gio.ApplicationFlags
19+ import ch.bailu.gtk.lib.bridge.GResource
2020import ch.bailu.gtk.type.Strs
2121import org.mapsforge.map.gtk.graphics.GtkGraphicFactory
2222import kotlin.system.exitProcess
Original file line number Diff line number Diff line change 1+ package ch.bailu.aat_gtk.lib
2+
3+ import ch.bailu.aat_lib.util.MemSize
4+ import ch.bailu.gtk.lib.util.SizeLog
5+
6+ class RuntimeInfo : Runnable {
7+ override fun run () {
8+ val max = SizeLog (getIdentifier(" Max" ))
9+ val total = SizeLog (getIdentifier(" Total" ))
10+ val free = SizeLog (getIdentifier(" Free" ))
11+ val used = SizeLog (getIdentifier(" Used" ))
12+ val processors = SizeLog (getIdentifier(" Processors" ))
13+
14+ val runtime = Runtime .getRuntime()
15+
16+ try {
17+ Thread .sleep(TIMEOUT )
18+ processors.log(runtime.availableProcessors().toLong())
19+ free.log(runtime.freeMemory() / MemSize .MB )
20+
21+ while (on) {
22+ max.log(runtime.maxMemory() / MemSize .MB )
23+ total.log(runtime.totalMemory() / MemSize .MB )
24+ used.log((runtime.totalMemory() - runtime.freeMemory()) / MemSize .MB )
25+ Thread .sleep(TIMEOUT )
26+ }
27+ } catch (e: InterruptedException ) {
28+ on = false
29+ System .err.println (e.message)
30+ }
31+ }
32+
33+ companion object {
34+ private const val TIMEOUT : Long = 5000
35+ private var on = false
36+
37+ private fun getIdentifier (name : String ): String {
38+ return Runtime ::class .java.simpleName + " :" + name
39+ }
40+
41+ @Synchronized
42+ fun startLogging () {
43+ if (! on) {
44+ on = true
45+ Thread (RuntimeInfo ()).start()
46+ }
47+ }
48+
49+ @Synchronized
50+ fun stopLogging () {
51+ on = false
52+ }
53+ }
54+ }
You can’t perform that action at this time.
0 commit comments