Skip to content

Commit

Permalink
another attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Jan 14, 2025
1 parent f107407 commit 4fe8d74
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion psutil/_psosx.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,15 @@

def virtual_memory():
"""System virtual memory as a namedtuple."""
total, active, inactive, wired, free, _speculative = cext.virtual_mem()
total, active, inactive, wired, free, speculative = cext.virtual_mem()
# This is how Zabbix calculate avail and used mem:
# https://github.com/zabbix/zabbix/blob/master/src/libs/zbxsysinfo/osx/memory.c
# Also see: https://github.com/giampaolo/psutil/issues/1277
avail = inactive + free
used = active + wired
# This is NOT how Zabbix calculates free mem but it matches "free"
# cmdline utility.
free -= speculative
percent = usage_percent((total - avail), total, round_=1)
return svmem(total, avail, percent, used, free, active, inactive, wired)

Expand Down
2 changes: 1 addition & 1 deletion psutil/arch/osx/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
static int
psutil_sys_vminfo(vm_statistics_data_t *vmstat) {
kern_return_t ret;
mach_msg_type_number_t count = sizeof(*vmstat) / sizeof(integer_t);
mach_msg_type_number_t count = HOST_VM_INFO_COUNT;
mach_port_t mport = mach_host_self();

ret = host_statistics(mport, HOST_VM_INFO, (host_info_t)vmstat, &count);
Expand Down

0 comments on commit 4fe8d74

Please sign in to comment.