summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2021-03-17 16:32:16 +0100
committerChristian Göttsche <cgzones@googlemail.com>2021-03-17 16:32:16 +0100
commit9f41dc3332a942eb4c578819e38cd40812656c2e (patch)
tree405204d3bbaf356b9eabfee16dd5429eecedc5d7
parentd9f2eacbc5b3fccf63b24944ce9a30d762baea3c (diff)
MemoryMeter: show shared memory before cached
Shared memory is less free-able than cached memory. Show it beforehand.
-rw-r--r--MemoryMeter.c18
-rw-r--r--darwin/Platform.c4
-rw-r--r--dragonflybsd/Platform.c4
-rw-r--r--freebsd/Platform.c4
-rw-r--r--linux/Platform.c6
-rw-r--r--openbsd/Platform.c4
-rw-r--r--solaris/Platform.c4
7 files changed, 27 insertions, 17 deletions
diff --git a/MemoryMeter.c b/MemoryMeter.c
index 0304bb9a..fe9ae20a 100644
--- a/MemoryMeter.c
+++ b/MemoryMeter.c
@@ -18,8 +18,8 @@ in the source distribution for its full text.
static const int MemoryMeter_attributes[] = {
MEMORY_USED,
MEMORY_BUFFERS,
- MEMORY_CACHE,
- MEMORY_SHARED
+ MEMORY_SHARED,
+ MEMORY_CACHE
};
static void MemoryMeter_updateValues(Meter* this) {
@@ -28,7 +28,7 @@ static void MemoryMeter_updateValues(Meter* this) {
int written;
/* shared and available memory are not supported on all platforms */
- this->values[3] = NAN;
+ this->values[2] = NAN;
this->values[4] = NAN;
Platform_setMemoryValues(this);
@@ -59,17 +59,17 @@ static void MemoryMeter_display(const Object* cast, RichString* out) {
RichString_appendAscii(out, CRT_colors[METER_TEXT], " buffers:");
RichString_appendAscii(out, CRT_colors[MEMORY_BUFFERS_TEXT], buffer);
- Meter_humanUnit(buffer, this->values[2], sizeof(buffer));
- RichString_appendAscii(out, CRT_colors[METER_TEXT], " cache:");
- RichString_appendAscii(out, CRT_colors[MEMORY_CACHE], buffer);
-
/* shared memory is not supported on all platforms */
- if (!isnan(this->values[3])) {
- Meter_humanUnit(buffer, this->values[3], sizeof(buffer));
+ if (!isnan(this->values[2])) {
+ Meter_humanUnit(buffer, this->values[2], sizeof(buffer));
RichString_appendAscii(out, CRT_colors[METER_TEXT], " shared:");
RichString_appendAscii(out, CRT_colors[MEMORY_SHARED], buffer);
}
+ Meter_humanUnit(buffer, this->values[3], sizeof(buffer));
+ RichString_appendAscii(out, CRT_colors[METER_TEXT], " cache:");
+ RichString_appendAscii(out, CRT_colors[MEMORY_CACHE], buffer);
+
/* available memory is not supported on all platforms */
if (!isnan(this->values[4])) {
Meter_humanUnit(buffer, this->values[4], sizeof(buffer));
diff --git a/darwin/Platform.c b/darwin/Platform.c
index 1d2b0f4f..932b1832 100644
--- a/darwin/Platform.c
+++ b/darwin/Platform.c
@@ -241,7 +241,9 @@ void Platform_setMemoryValues(Meter* mtr) {
mtr->total = dpl->host_info.max_mem / 1024;
mtr->values[0] = (double)(vm->active_count + vm->wire_count) * page_K;
mtr->values[1] = (double)vm->purgeable_count * page_K;
- mtr->values[2] = (double)vm->inactive_count * page_K;
+ // mtr->values[2] = "shared memory, like tmpfs and shm"
+ mtr->values[3] = (double)vm->inactive_count * page_K;
+ // mtr->values[4] = "available memory"
}
void Platform_setSwapValues(Meter* mtr) {
diff --git a/dragonflybsd/Platform.c b/dragonflybsd/Platform.c
index 3646e33a..1bbbf2c4 100644
--- a/dragonflybsd/Platform.c
+++ b/dragonflybsd/Platform.c
@@ -200,7 +200,9 @@ void Platform_setMemoryValues(Meter* this) {
this->total = pl->totalMem;
this->values[0] = pl->usedMem;
this->values[1] = pl->buffersMem;
- this->values[2] = pl->cachedMem;
+ // this->values[2] = "shared memory, like tmpfs and shm"
+ this->values[3] = pl->cachedMem;
+ // this->values[4] = "available memory"
}
void Platform_setSwapValues(Meter* this) {
diff --git a/freebsd/Platform.c b/freebsd/Platform.c
index 1d35819a..a3c24315 100644
--- a/freebsd/Platform.c
+++ b/freebsd/Platform.c
@@ -221,7 +221,9 @@ void Platform_setMemoryValues(Meter* this) {
this->total = pl->totalMem;
this->values[0] = pl->usedMem;
this->values[1] = pl->buffersMem;
- this->values[2] = pl->cachedMem;
+ // this->values[2] = "shared memory, like tmpfs and shm"
+ this->values[3] = pl->cachedMem;
+ // this->values[4] = "available memory"
}
void Platform_setSwapValues(Meter* this) {
diff --git a/linux/Platform.c b/linux/Platform.c
index 052a29cb..1655c7df 100644
--- a/linux/Platform.c
+++ b/linux/Platform.c
@@ -286,13 +286,13 @@ void Platform_setMemoryValues(Meter* this) {
this->total = pl->totalMem > lpl->totalHugePageMem ? pl->totalMem - lpl->totalHugePageMem : pl->totalMem;
this->values[0] = pl->usedMem > lpl->totalHugePageMem ? pl->usedMem - lpl->totalHugePageMem : pl->usedMem;
this->values[1] = pl->buffersMem;
- this->values[2] = pl->cachedMem;
- this->values[3] = pl->sharedMem;
+ this->values[2] = pl->sharedMem;
+ this->values[3] = pl->cachedMem;
this->values[4] = pl->availableMem;
if (lpl->zfs.enabled != 0) {
this->values[0] -= lpl->zfs.size;
- this->values[2] += lpl->zfs.size;
+ this->values[3] += lpl->zfs.size;
}
}
diff --git a/openbsd/Platform.c b/openbsd/Platform.c
index 606869a5..c57e6cc3 100644
--- a/openbsd/Platform.c
+++ b/openbsd/Platform.c
@@ -208,7 +208,9 @@ void Platform_setMemoryValues(Meter* this) {
this->total = pl->totalMem;
this->values[0] = usedMem;
this->values[1] = buffersMem;
- this->values[2] = cachedMem;
+ // this->values[2] = "shared memory, like tmpfs and shm"
+ this->values[3] = cachedMem;
+ // this->values[4] = "available memory"
}
void Platform_setSwapValues(Meter* this) {
diff --git a/solaris/Platform.c b/solaris/Platform.c
index 6a2ab312..aa000e29 100644
--- a/solaris/Platform.c
+++ b/solaris/Platform.c
@@ -218,7 +218,9 @@ void Platform_setMemoryValues(Meter* this) {
this->total = pl->totalMem;
this->values[0] = pl->usedMem;
this->values[1] = pl->buffersMem;
- this->values[2] = pl->cachedMem;
+ // this->values[2] = "shared memory, like tmpfs and shm"
+ this->values[3] = pl->cachedMem;
+ // this->values[4] = "available memory"
}
void Platform_setSwapValues(Meter* this) {

© 2014-2024 Faster IT GmbH | imprint | privacy policy