Skip to content

Commit 638fa69

Browse files
committed
fix: other memory
1 parent 3b55c19 commit 638fa69

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

src/components/MemoryViewer/MemoryViewer.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ $memory-type-colors: (
55
'SharedCacheConsumption': var(--g-color-base-info-medium-hover),
66
'MemTableConsumption': var(--g-color-base-warning-medium-hover),
77
'QueryExecutionConsumption': var(--g-color-base-positive-medium-hover),
8+
'Other': var(--g-color-base-neutral-light-hover),
89
);
910

1011
@mixin memory-type-color($type) {

src/components/MemoryViewer/i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
"text_query-execution": "Query Execution",
88
"text_soft-limit": "Soft Limit",
99
"text_hard-limit": "Hard Limit",
10+
"text_other": "Other",
1011
"memory-detailed": "Memory Detailed"
1112
}

src/components/MemoryViewer/utils.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,49 @@ export function getMemorySegments(stats: TMemoryStats): MemorySegment[] {
2222
key: 'SharedCacheConsumption',
2323
value: getMaybeNumber(stats.SharedCacheConsumption),
2424
capacity: getMaybeNumber(stats.SharedCacheLimit),
25+
isInfo: false,
2526
},
2627
{
2728
label: i18n('text_query-execution'),
2829
key: 'QueryExecutionConsumption',
2930
value: getMaybeNumber(stats.QueryExecutionConsumption),
3031
capacity: getMaybeNumber(stats.QueryExecutionLimit),
32+
isInfo: false,
3133
},
3234
{
3335
label: i18n('text_memtable'),
3436
key: 'MemTableConsumption',
3537
value: getMaybeNumber(stats.MemTableConsumption),
3638
capacity: getMaybeNumber(stats.MemTableLimit),
39+
isInfo: false,
3740
},
3841
{
3942
label: i18n('text_allocator-caches'),
4043
key: 'AllocatorCachesMemory',
4144
value: getMaybeNumber(stats.AllocatorCachesMemory),
45+
isInfo: false,
4246
},
47+
];
48+
49+
const nonInfoSegments = segments.filter(
50+
(segment) => segment.value !== undefined,
51+
) as MemorySegment[];
52+
const sumNonInfoSegments = nonInfoSegments.reduce((acc, segment) => acc + segment.value, 0);
53+
54+
const totalMemory = getMaybeNumber(stats.AnonRss);
55+
56+
if (totalMemory) {
57+
const otherMemory = Math.max(0, totalMemory - sumNonInfoSegments);
58+
59+
segments.push({
60+
label: i18n('text_other'),
61+
key: 'Other',
62+
value: otherMemory,
63+
isInfo: false,
64+
});
65+
}
66+
67+
segments.push(
4368
{
4469
label: i18n('text_external-consumption'),
4570
key: 'ExternalConsumption',
@@ -58,7 +83,7 @@ export function getMemorySegments(stats: TMemoryStats): MemorySegment[] {
5883
value: getMaybeNumber(stats.HardLimit),
5984
isInfo: true,
6085
},
61-
];
86+
);
6287

6388
return segments.filter((segment) => segment.value !== undefined) as MemorySegment[];
6489
}

0 commit comments

Comments
 (0)