diff --git a/DisplayOptionsPanel.c b/DisplayOptionsPanel.c index 8fa347294..48489f9e3 100644 --- a/DisplayOptionsPanel.c +++ b/DisplayOptionsPanel.c @@ -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 diff --git a/MemoryMeter.c b/MemoryMeter.c index 3b7835256..36401cb79 100644 --- a/MemoryMeter.c +++ b/MemoryMeter.c @@ -33,12 +33,17 @@ 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 || this->mode == BAR_METERMODE) && !settings->showCachedMemory) { + this->values[MEMORY_METER_BUFFERS] = 0; + this->values[MEMORY_METER_CACHE] = 0; + } /* 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"); diff --git a/Settings.c b/Settings.c index 92cd85427..fa473d1a1 100644 --- a/Settings.c +++ b/Settings.c @@ -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]); @@ -697,6 +699,7 @@ int Settings_write(const Settings* this, bool onCrash) { printSettingInteger("show_cpu_temperature", this->showCPUTemperature); printSettingInteger("degree_fahrenheit", this->degreeFahrenheit); #endif + printSettingInteger("show_cached_memory", this->showCachedMemory); printSettingInteger("update_process_names", this->updateProcessNames); printSettingInteger("account_guest_in_cpu_meter", this->accountGuestInCPUMeter); printSettingInteger("color_scheme", this->colorScheme); @@ -801,6 +804,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; diff --git a/Settings.h b/Settings.h index 5d17fb346..01e808e86 100644 --- a/Settings.h +++ b/Settings.h @@ -101,6 +101,7 @@ typedef struct Settings_ { bool accountGuestInCPUMeter; bool headerMargin; bool screenTabs; + bool showCachedMemory; #ifdef HAVE_GETMOUSE bool enableMouse; #endif