diff options
author | Kevin Bracey <kevin@bracey.fi> | 2022-01-09 13:27:52 +0200 |
---|---|---|
committer | Ivan Shapovalov <intelfx@intelfx.name> | 2023-10-26 03:24:50 +0400 |
commit | fe3dedf5ba4a898a765c647af294f61d807ce364 (patch) | |
tree | 624c7681478358fdad97bab12bd3a75697035a5f /MemoryMeter.c | |
parent | 69a505d69cb69018b1581103e0dcbab5f7a0d6b1 (diff) |
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).]
Diffstat (limited to 'MemoryMeter.c')
-rw-r--r-- | MemoryMeter.c | 4 |
1 files changed, 3 insertions, 1 deletions
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]; |