Skip to content

Commit

Permalink
Add option to show or hide Cache and Buffers from Graph
Browse files Browse the repository at this point in the history
  • Loading branch information
batk0 committed Sep 25, 2024
1 parent 9c316cc commit 3f2fdcc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions DisplayOptionsPanel.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ DisplayOptionsPanel* DisplayOptionsPanel_new(Settings* settings, ScreenManager*
&(settings->showCPUTemperature)));
Panel_add(super, (Object*) CheckItem_newByRef("- Show temperature in degree Fahrenheit instead of Celsius", &(settings->degreeFahrenheit)));
#endif
Panel_add(super, (Object *)CheckItem_newByRef("Show cached memory in graph", &(settings->showCachedMemory)));
#ifdef HAVE_GETMOUSE
Panel_add(super, (Object*) CheckItem_newByRef("Enable the mouse", &(settings->enableMouse)));
#endif
Expand Down
10 changes: 8 additions & 2 deletions MemoryMeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,21 @@ static void MemoryMeter_updateValues(Meter* this) {
size_t size = sizeof(this->txtBuffer);
int written;

Settings *settings = this->host->settings;

/* shared, compressed and available memory are not supported on all platforms */
this->values[MEMORY_METER_SHARED] = NAN;
this->values[MEMORY_METER_COMPRESSED] = NAN;
this->values[MEMORY_METER_AVAILABLE] = NAN;
Platform_setMemoryValues(this);

if (this->mode == GRAPH_METERMODE && !settings->showCachedMemory)
{
this->values[MEMORY_METER_BUFFERS] = NAN;
this->values[MEMORY_METER_CACHE] = NAN;
}
/* Do not print available memory in bar mode */
static_assert(MEMORY_METER_AVAILABLE + 1 == MEMORY_METER_ITEMCOUNT,
"MEMORY_METER_AVAILABLE is not the last item in MemoryMeterValues");
"MEMORY_METER_AVAILABLE is not the last item in MemoryMeterValues");
this->curItems = MEMORY_METER_AVAILABLE;

/* we actually want to show "used + shared + compressed" */
Expand Down
3 changes: 3 additions & 0 deletions Settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,8 @@ static bool Settings_read(Settings* this, const char* fileName, const Machine* h
this->showCPUUsage = atoi(option[1]);
} else if (String_eq(option[0], "show_cpu_frequency")) {
this->showCPUFrequency = atoi(option[1]);
} else if (String_eq(option[0], "show_cached_memory")) {
this->showCachedMemory = atoi(option[1]);
#ifdef BUILD_WITH_CPU_TEMP
} else if (String_eq(option[0], "show_cpu_temperature")) {
this->showCPUTemperature = atoi(option[1]);
Expand Down Expand Up @@ -801,6 +803,7 @@ Settings* Settings_new(const Machine* host, Hashtable* dynamicMeters, Hashtable*
this->showCPUTemperature = false;
this->degreeFahrenheit = false;
#endif
this->showCachedMemory = true;
this->updateProcessNames = false;
this->showProgramPath = true;
this->highlightThreads = true;
Expand Down
1 change: 1 addition & 0 deletions Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ typedef struct Settings_ {
bool accountGuestInCPUMeter;
bool headerMargin;
bool screenTabs;
bool showCachedMemory;
#ifdef HAVE_GETMOUSE
bool enableMouse;
#endif
Expand Down

0 comments on commit 3f2fdcc

Please sign in to comment.