summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Bracey <kevin@bracey.fi>2022-01-09 13:27:52 +0200
committerIvan Shapovalov <intelfx@intelfx.name>2023-10-26 03:14:33 +0400
commit69a505d69cb69018b1581103e0dcbab5f7a0d6b1 (patch)
tree0353879bf12086f2bccde9140aa08a4d1966f186
parent09934e6630621f05e8c339c0633ef9eb24f1fc2c (diff)
Move shared memory next to used memory
Shared memory is less available than buffers, so move it left next to used memory. This is in preparation for including shared memory in the basic "in use" for the bar text. It would not make sense to sum a discontiguous region.
-rw-r--r--Action.c2
-rw-r--r--MemoryMeter.c10
-rw-r--r--MemoryMeter.h6
-rw-r--r--darwin/Platform.c2
-rw-r--r--dragonflybsd/Platform.c4
-rw-r--r--freebsd/Platform.c2
-rw-r--r--linux/Platform.c2
-rw-r--r--netbsd/Platform.c2
-rw-r--r--openbsd/Platform.c2
-rw-r--r--solaris/Platform.c2
10 files changed, 17 insertions, 17 deletions
diff --git a/Action.c b/Action.c
index 2fd0be76..698b1525 100644
--- a/Action.c
+++ b/Action.c
@@ -733,9 +733,9 @@ static Htop_Reaction actionHelp(State* st) {
mvaddstr(line++, 0, "Memory bar: ");
addattrstr(CRT_colors[BAR_BORDER], "[");
addbartext(CRT_colors[MEMORY_USED], "", "used");
- addbartext(CRT_colors[MEMORY_BUFFERS_TEXT], "/", "buffers");
addbartext(CRT_colors[MEMORY_SHARED], "/", "shared");
addbartext(CRT_colors[MEMORY_COMPRESSED], "/", "compressed");
+ addbartext(CRT_colors[MEMORY_BUFFERS_TEXT], "/", "buffers");
addbartext(CRT_colors[MEMORY_CACHE], "/", "cache");
addbartext(CRT_colors[BAR_SHADOW], " ", "used");
addbartext(CRT_colors[BAR_SHADOW], "/", "total");
diff --git a/MemoryMeter.c b/MemoryMeter.c
index c7d99f88..3ddb0438 100644
--- a/MemoryMeter.c
+++ b/MemoryMeter.c
@@ -19,9 +19,9 @@ in the source distribution for its full text.
static const int MemoryMeter_attributes[] = {
MEMORY_USED,
- MEMORY_BUFFERS,
MEMORY_SHARED,
MEMORY_COMPRESSED,
+ MEMORY_BUFFERS,
MEMORY_CACHE
};
@@ -66,10 +66,6 @@ static void MemoryMeter_display(const Object* cast, RichString* out) {
RichString_appendAscii(out, CRT_colors[METER_TEXT], " used:");
RichString_appendAscii(out, CRT_colors[MEMORY_USED], buffer);
- Meter_humanUnit(buffer, this->values[MEMORY_METER_BUFFERS], sizeof(buffer));
- RichString_appendAscii(out, CRT_colors[METER_TEXT], " buffers:");
- RichString_appendAscii(out, CRT_colors[MEMORY_BUFFERS_TEXT], buffer);
-
/* shared memory is not supported on all platforms */
if (isNonnegative(this->values[MEMORY_METER_SHARED])) {
Meter_humanUnit(buffer, this->values[MEMORY_METER_SHARED], sizeof(buffer));
@@ -84,6 +80,10 @@ static void MemoryMeter_display(const Object* cast, RichString* out) {
RichString_appendAscii(out, CRT_colors[MEMORY_COMPRESSED], buffer);
}
+ Meter_humanUnit(buffer, this->values[MEMORY_METER_BUFFERS], sizeof(buffer));
+ RichString_appendAscii(out, CRT_colors[METER_TEXT], " buffers:");
+ RichString_appendAscii(out, CRT_colors[MEMORY_BUFFERS_TEXT], buffer);
+
Meter_humanUnit(buffer, this->values[MEMORY_METER_CACHE], sizeof(buffer));
RichString_appendAscii(out, CRT_colors[METER_TEXT], " cache:");
RichString_appendAscii(out, CRT_colors[MEMORY_CACHE], buffer);
diff --git a/MemoryMeter.h b/MemoryMeter.h
index b6568afc..e39b3bd3 100644
--- a/MemoryMeter.h
+++ b/MemoryMeter.h
@@ -11,9 +11,9 @@ in the source distribution for its full text.
typedef enum {
MEMORY_METER_USED = 0,
- MEMORY_METER_BUFFERS = 1,
- MEMORY_METER_SHARED = 2,
- MEMORY_METER_COMPRESSED = 3,
+ MEMORY_METER_SHARED = 1,
+ MEMORY_METER_COMPRESSED = 2,
+ MEMORY_METER_BUFFERS = 3,
MEMORY_METER_CACHE = 4,
MEMORY_METER_AVAILABLE = 5,
MEMORY_METER_ITEMCOUNT = 6, // number of entries in this enum
diff --git a/darwin/Platform.c b/darwin/Platform.c
index 6a9c2184..f72f8aec 100644
--- a/darwin/Platform.c
+++ b/darwin/Platform.c
@@ -292,9 +292,9 @@ void Platform_setMemoryValues(Meter* mtr) {
mtr->total = dhost->host_info.max_mem / 1024;
mtr->values[MEMORY_METER_USED] = (double)(vm->active_count + vm->wire_count) * page_K;
- mtr->values[MEMORY_METER_BUFFERS] = (double)vm->purgeable_count * page_K;
// mtr->values[MEMORY_METER_SHARED] = "shared memory, like tmpfs and shm"
// mtr->values[MEMORY_METER_COMPRESSED] = "compressed memory, like zswap on linux"
+ mtr->values[MEMORY_METER_BUFFERS] = (double)vm->purgeable_count * page_K;
mtr->values[MEMORY_METER_CACHE] = (double)vm->inactive_count * page_K;
// mtr->values[MEMORY_METER_AVAILABLE] = "available memory"
}
diff --git a/dragonflybsd/Platform.c b/dragonflybsd/Platform.c
index d94d7a18..ff2300aa 100644
--- a/dragonflybsd/Platform.c
+++ b/dragonflybsd/Platform.c
@@ -214,9 +214,9 @@ void Platform_setMemoryValues(Meter* this) {
this->total = host->totalMem;
this->values[MEMORY_METER_USED] = host->usedMem;
- this->values[MEMORY_METER_BUFFERS] = host->buffersMem;
// this->values[MEMORY_METER_SHARED] = "shared memory, like tmpfs and shm"
- // mtr->values[MEMORY_METER_COMPRESSED] = "compressed memory, like zswap on linux"
+ // this->values[MEMORY_METER_COMPRESSED] = "compressed memory, like zswap on linux"
+ this->values[MEMORY_METER_BUFFERS] = host->buffersMem;
this->values[MEMORY_METER_CACHE] = host->cachedMem;
// this->values[MEMORY_METER_AVAILABLE] = "available memory"
}
diff --git a/freebsd/Platform.c b/freebsd/Platform.c
index 9b8981ad..9be7195e 100644
--- a/freebsd/Platform.c
+++ b/freebsd/Platform.c
@@ -229,9 +229,9 @@ void Platform_setMemoryValues(Meter* this) {
this->total = host->totalMem;
this->values[MEMORY_METER_USED] = host->usedMem;
- this->values[MEMORY_METER_BUFFERS] = host->buffersMem;
this->values[MEMORY_METER_SHARED] = host->sharedMem;
// this->values[MEMORY_METER_COMPRESSED] = "compressed memory, like zswap on linux"
+ this->values[MEMORY_METER_BUFFERS] = host->buffersMem;
this->values[MEMORY_METER_CACHE] = host->cachedMem;
// this->values[MEMORY_METER_AVAILABLE] = "available memory"
diff --git a/linux/Platform.c b/linux/Platform.c
index 65f7558e..fbbedc6e 100644
--- a/linux/Platform.c
+++ b/linux/Platform.c
@@ -360,9 +360,9 @@ void Platform_setMemoryValues(Meter* this) {
this->total = host->totalMem;
this->values[MEMORY_METER_USED] = host->usedMem;
- this->values[MEMORY_METER_BUFFERS] = host->buffersMem;
this->values[MEMORY_METER_SHARED] = host->sharedMem;
this->values[MEMORY_METER_COMPRESSED] = 0; /* compressed */
+ this->values[MEMORY_METER_BUFFERS] = host->buffersMem;
this->values[MEMORY_METER_CACHE] = host->cachedMem;
this->values[MEMORY_METER_AVAILABLE] = host->availableMem;
diff --git a/netbsd/Platform.c b/netbsd/Platform.c
index 8231cdfd..5b09ed16 100644
--- a/netbsd/Platform.c
+++ b/netbsd/Platform.c
@@ -272,9 +272,9 @@ void Platform_setMemoryValues(Meter* this) {
const Machine* host = this->host;
this->total = host->totalMem;
this->values[MEMORY_METER_USED] = host->usedMem;
- this->values[MEMORY_METER_BUFFERS] = host->buffersMem;
// this->values[MEMORY_METER_SHARED] = "shared memory, like tmpfs and shm"
// this->values[MEMORY_METER_COMPRESSED] = "compressed memory, like zswap on linux"
+ this->values[MEMORY_METER_BUFFERS] = host->buffersMem;
this->values[MEMORY_METER_CACHE] = host->cachedMem;
// this->values[MEMORY_METER_AVAILABLE] = "available memory"
}
diff --git a/openbsd/Platform.c b/openbsd/Platform.c
index 267da703..b41900b0 100644
--- a/openbsd/Platform.c
+++ b/openbsd/Platform.c
@@ -229,9 +229,9 @@ void Platform_setMemoryValues(Meter* this) {
usedMem -= buffersMem + cachedMem;
this->total = host->totalMem;
this->values[MEMORY_METER_USED] = usedMem;
- this->values[MEMORY_METER_BUFFERS] = buffersMem;
// this->values[MEMORY_METER_SHARED] = "shared memory, like tmpfs and shm"
// this->values[MEMORY_METER_COMPRESSED] = "compressed memory, like zswap on linux"
+ this->values[MEMORY_METER_BUFFERS] = buffersMem;
this->values[MEMORY_METER_CACHE] = cachedMem;
// this->values[MEMORY_METER_AVAILABLE] = "available memory"
}
diff --git a/solaris/Platform.c b/solaris/Platform.c
index 5117a448..c4b121c7 100644
--- a/solaris/Platform.c
+++ b/solaris/Platform.c
@@ -240,9 +240,9 @@ void Platform_setMemoryValues(Meter* this) {
const Machine* host = this->host;
this->total = host->totalMem;
this->values[MEMORY_METER_USED] = host->usedMem;
- this->values[MEMORY_METER_BUFFERS] = host->buffersMem;
// this->values[MEMORY_METER_SHARED] = "shared memory, like tmpfs and shm"
// this->values[MEMORY_METER_COMPRESSED] = "compressed memory, like zswap on linux"
+ this->values[MEMORY_METER_BUFFERS] = host->buffersMem;
this->values[MEMORY_METER_CACHE] = host->cachedMem;
// this->values[MEMORY_METER_AVAILABLE] = "available memory"
}

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