Skip to content

Commit b4fce9b

Browse files
committed
cleanup
1 parent ea03eb7 commit b4fce9b

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/main/java/com/samourai/javaserver/web/models/SystemTemplateModel.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ public SystemTemplateModel(String pageTitle, String logoTitle) {
2929

3030
// memory
3131
Runtime rt = Runtime.getRuntime();
32-
memTotal = rt.totalMemory();
32+
long total = rt.totalMemory();
3333
long free = rt.freeMemory();
34-
memUsed = memTotal - free;
34+
memUsed = bytesToMB(total - free);
35+
memTotal = bytesToMB(total);
3536
}
3637

3738
public void apply(Model model) {
@@ -40,4 +41,8 @@ public void apply(Model model) {
4041
model.addAttribute("memUsed", memUsed);
4142
model.addAttribute("memTotal", memTotal);
4243
}
44+
45+
private static long bytesToMB(long bytes) {
46+
return Math.round(bytes / (1024L * 1024L));
47+
}
4348
}

src/main/resources/templates/decorators/system.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<div layout:fragment="main">
1313
<h1 class="h2">System</h1>
1414

15-
<div>Mem use: <strong th:text="${memUsed}M"/>/<span th:text="${memTotal}M"/></div>
15+
<div>Mem use: <strong th:text="${memUsed}"/>M/<span th:text="${memTotal}"/>M</div>
1616
<div><strong th:text="${threads.size()}"/> threads running.</div>
1717
<div class="table-responsive">
1818
<table class="table table-sm system">

0 commit comments

Comments
 (0)