Skip to content

Commit e804dfc

Browse files
committed
Memory (macOS): align algo of memory usage counting to stats
Which seems to print the same result of neofetch
1 parent 8048101 commit e804dfc

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Features:
99

1010
Bugfixes:
1111
* Fix crashes sometimes when `--logo-padding-top` is not set (Logo)
12+
* Fix memory usage counting algorithm (Memory, macOS)
1213

1314
# 2.3.4
1415

src/detection/memory/memory_apple.c

+10-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,16 @@ const char* ffDetectMemory(FFMemoryResult* ram)
1616
if(host_statistics64(mach_host_self(), HOST_VM_INFO64, (host_info64_t) (&vmstat), &count) != KERN_SUCCESS)
1717
return "Failed to read host_statistics64";
1818

19-
ram->bytesUsed = ((uint64_t) vmstat.active_count + vmstat.wire_count) * instance.state.platform.pageSize;
19+
// https://github.com/exelban/stats/blob/master/Modules/RAM/readers.swift#L56
20+
ram->bytesUsed = ((uint64_t)
21+
+ vmstat.active_count
22+
+ vmstat.inactive_count
23+
+ vmstat.speculative_count
24+
+ vmstat.wire_count
25+
+ vmstat.compressor_page_count
26+
- vmstat.purgeable_count
27+
- vmstat.external_page_count
28+
) * instance.state.platform.pageSize;
2029

2130
return NULL;
2231
}

0 commit comments

Comments
 (0)