Skip to content

Commit

Permalink
Memory (macOS): align algo of memory usage counting to stats
Browse files Browse the repository at this point in the history
Which seems to print the same result of neofetch
  • Loading branch information
CarterLi committed Dec 14, 2023
1 parent 8048101 commit e804dfc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Features:

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

# 2.3.4

Expand Down
11 changes: 10 additions & 1 deletion src/detection/memory/memory_apple.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,16 @@ const char* ffDetectMemory(FFMemoryResult* ram)
if(host_statistics64(mach_host_self(), HOST_VM_INFO64, (host_info64_t) (&vmstat), &count) != KERN_SUCCESS)
return "Failed to read host_statistics64";

ram->bytesUsed = ((uint64_t) vmstat.active_count + vmstat.wire_count) * instance.state.platform.pageSize;
// https://github.com/exelban/stats/blob/master/Modules/RAM/readers.swift#L56
ram->bytesUsed = ((uint64_t)
+ vmstat.active_count
+ vmstat.inactive_count
+ vmstat.speculative_count
+ vmstat.wire_count
+ vmstat.compressor_page_count
- vmstat.purgeable_count
- vmstat.external_page_count
) * instance.state.platform.pageSize;

return NULL;
}

0 comments on commit e804dfc

Please sign in to comment.