Skip to content

Commit

Permalink
Move shared memory next to used memory
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kjbracey2 authored and intelfx committed Oct 25, 2023
1 parent 09934e6 commit 69a505d
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Action.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
10 changes: 5 additions & 5 deletions MemoryMeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down Expand Up @@ -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));
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions MemoryMeter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion darwin/Platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
4 changes: 2 additions & 2 deletions dragonflybsd/Platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
2 changes: 1 addition & 1 deletion freebsd/Platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion linux/Platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion netbsd/Platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
2 changes: 1 addition & 1 deletion openbsd/Platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
2 changes: 1 addition & 1 deletion solaris/Platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down

0 comments on commit 69a505d

Please sign in to comment.