Skip to content

Commit d5a72cd

Browse files
committed
improve description
1 parent d1654a8 commit d5a72cd

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

utils/Utils.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,22 +301,23 @@ void Utils::printProcesses(const QDateTime &time,
301301
return buffer.str();
302302
};
303303

304-
size_t rssAnonSum = 0;
304+
int64_t rssAnonSum = 0;
305305
for (auto const &proc: processes) {
306+
// take just anonymous process memory, part of pss is counted to cached already
306307
rssAnonSum += (proc.statm.resident - proc.statm.shared);
307308
}
308-
size_t computedAvailable = memInfo.memFree + memInfo.buffers + (memInfo.cached - memInfo.shmem) + memInfo.swapCache + memInfo.sReclaimable;
309-
size_t otherMem = memInfo.memTotal - rssAnonSum - memInfo.slab - memInfo.memFree - memInfo.buffers - memInfo.cached - memInfo.swapCache;
309+
int64_t otherMem = memInfo.memTotal - rssAnonSum - memInfo.slab - memInfo.memFree - memInfo.buffers - memInfo.cached - memInfo.swapCache;
310+
int64_t computedAvailable = memInfo.memFree + memInfo.buffers + (memInfo.cached - memInfo.shmem) + memInfo.swapCache + memInfo.sReclaimable;
310311

311312
std::cout << "Memory details: " << f(memInfo.memTotal) << " total, " << f(memInfo.memFree) << " free, "
312313
<< f(memInfo.buffers) << " buffers, " << f(memInfo.cached) << " cached (including " << f(memInfo.shmem) << " shmem (tmpfs)), "
313314
<< f(memInfo.swapCache) << " swap cache" << std::endl;
314315
std::cout << "Kernel: " << f(memInfo.slab) << " SLAB (" << f(memInfo.sReclaimable) << " reclaimable), " << std::endl
315-
<< " ~ " << f(otherMem) << " other kernel memory?" << std::endl;
316+
<< " ~ " << f(otherMem) << " other kernel memory? It means: total - anonymous process - slab - free - buffers - cached - swap cache" << std::endl;
316317
std::cout << "Swap: " << f(memInfo.swapTotal) << " total, " << f(memInfo.swapFree) << " free (" << p(memInfo.swapFree, memInfo.swapTotal) << ")"<< std::endl;
317318
std::cout << "Available: " << f(memInfo.memAvailable) << " (" << p(memInfo.memAvailable, memInfo.memTotal) << ") estimated by kernel" << std::endl;
318319
std::cout << " " << f(computedAvailable) << " (" << p(computedAvailable, memInfo.memTotal) << ")"
319-
<< " computed. It means: MemFree + Buffers + (Cached - Shmem) + SwapCache + SReclaimable" << std::endl;
320+
<< " computed. It means: free + buffers + (cached - Shmem) + swap cache + slab reclaimable" << std::endl;
320321

321322

322323
std::cout << std::endl;

0 commit comments

Comments
 (0)