From fe3dedf5ba4a898a765c647af294f61d807ce364 Mon Sep 17 00:00:00 2001 From: Kevin Bracey Date: Sun, 9 Jan 2022 13:27:52 +0200 Subject: Incorporate shared memory in bar text Shared memory is not available for reclaim, and plays an equally significant role in memory load as the "used" memory Since "shared" was separated from the "used" value, the basic "used/total" display in the bar text has become less meaningful for Linux, as it only reflects a subset of the claimed memory. The difference often isn't huge, but it can become so if tmpfs, shmget()/shm_open() or MAP_SHARED is heavily used. Improve the situation by adding shared memory to the "used" value in the memory bar text. [Reworded commit message and dropped "claimed" terminology as it is completely non-standard and does not match the output of free(1).] --- MemoryMeter.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'MemoryMeter.c') diff --git a/MemoryMeter.c b/MemoryMeter.c index 3ddb0438..6483e95f 100644 --- a/MemoryMeter.c +++ b/MemoryMeter.c @@ -41,8 +41,10 @@ static void MemoryMeter_updateValues(Meter* this) { "MEMORY_METER_AVAILABLE is not the last item in MemoryMeterValues"); this->curItems = MEMORY_METER_AVAILABLE; - /* we actually want to show "used + compressed" */ + /* we actually want to show "used + shared + compressed" */ double used = this->values[MEMORY_METER_USED]; + if (isPositive(this->values[MEMORY_METER_SHARED])) + used += this->values[MEMORY_METER_SHARED]; if (isPositive(this->values[MEMORY_METER_COMPRESSED])) used += this->values[MEMORY_METER_COMPRESSED]; -- cgit v1.2.3