Skip to content

Commit

Permalink
ui: fix bug where allocation memory usage is always zero
Browse files Browse the repository at this point in the history
This PR fixes a bug where allocation memory usage is always zero on
Linux systems where the kernel is configured to use cgroups v2.
  • Loading branch information
shoenig committed Aug 2, 2022
1 parent 2e0b875 commit 17000ba
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions ui/app/utils/classes/allocation-stats-tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ class AllocationStatsTracker extends EmberObject.extend(AbstractStatsTracker) {
percent: percent(cpuUsed, this.reservedCPU),
});

const memoryUsed = frame.ResourceUsage.MemoryStats.RSS;
let memoryUsed = 0;
if (frame.ResourceUsage.MemoryStats.Usage) {
memoryUsed = frame.ResourceUsage.MemoryStats.Usage;
} else {
memoryUsed = frame.ResourceUsage.MemoryStats.RSS;
}

this.memory.pushObject({
timestamp,
used: memoryUsed,
Expand Down Expand Up @@ -80,7 +86,13 @@ class AllocationStatsTracker extends EmberObject.extend(AbstractStatsTracker) {
percentStack: percentCpuTotal + aggregateCpu,
});

const taskMemoryUsed = taskFrame.ResourceUsage.MemoryStats.RSS;
let taskMemoryUsed = 0;
if (frame.ResourceUsage.MemoryStats.Usage) {
taskMemoryUsed = frame.ResourceUsage.MemoryStats.Usage;
} else {
taskMemoryUsed = frame.ResourceUsage.MemoryStats.RSS;
}

const percentMemoryTotal = percent(
taskMemoryUsed / 1024 / 1024,
this.reservedMemory
Expand Down

0 comments on commit 17000ba

Please sign in to comment.