-
-
Notifications
You must be signed in to change notification settings - Fork 679
Closed
samuelvenable/fastfetch
#12Labels
bugSomething isn't workingSomething isn't working
Description
Read the FAQ first
- I have checked the FAQ but the issue is not covered
Description
I have tried getting memory usage with fastfetch but it is not matching up with Activity Monitor. If you don't feel like compiling anything, here's a quick shell script which gets ram usage much closer to how Activity Monitor does it, (if not exactly how it does it, it's very close): https://gist.github.com/samuelvenable/550bb8922a4bc137aa9b240fa694c020
#!/bin/sh
# macOS Memory Usage Statistics Shell Script
# Show Physical Memory and Memory Used Stats
# This Matches Up with Activity Monitor App!
# View vm_stat Source Code for More Details:
# https://github.com/st3fan/osx-10.9/blob/34e34a6a539b5a822cda4074e56a7ced9b57da71/system_cmds-597.1.1/vm_stat.tproj/vm_stat.c#L135-L160
free_count=$(vm_stat | grep "Pages free:" | awk '{gsub(/\./, "");print $3}')
external_page_count=$(vm_stat | grep "File-backed pages:" | awk '{gsub(/\./, "");print $3}')
page_size=$(vm_stat | grep "page size of" | awk '{print $8}')
free_page_count=$((free_count + external_page_count))
physical_memory=$(sysctl -n hw.memsize)
free_memory=$((free_page_count * page_size))
used_memory=$((physical_memory - free_memory))
gb_physical_memory=$(awk -v physical_memory="$physical_memory" 'BEGIN{result=physical_memory / 1024 / 1024 / 1024;print result}')
gb_free_memory=$(awk -F'.' -v used_memory="$used_memory" 'BEGIN{result=used_memory / 1024 / 1024 / 1024;print result}')
gb_used_memory=$(awk -F'.' -v free_memory="$free_memory" 'BEGIN{result=free_memory / 1024 / 1024 / 1024;print result}')
truncated_gb_physical_memory=$(awk -F'.' -v gb_physical_memory="$gb_physical_memory" 'BEGIN{printf "%.2f",gb_physical_memory}')
truncated_gb_free_memory=$(awk -F'.' -v gb_used_memory="$gb_used_memory" 'BEGIN{printf "%.2f",gb_used_memory}')
truncated_gb_used_memory=$(awk -F'.' -v gb_free_memory="$gb_free_memory" 'BEGIN{printf "%.2f",gb_free_memory}')
echo Physical Memory: $truncated_gb_physical_memory GB
echo Memory Used: $truncated_gb_used_memory GB
echo Memory Free: $truncated_gb_free_memory GBC equivalent:
#include "memory.h"
#include <string.h>
#include <mach/mach.h>
#include <sys/sysctl.h>
#include <unistd.h>
const char* ffDetectMemory(FFMemoryResult* ram)
{
size_t length = sizeof(ram->bytesTotal);
if (sysctl((int[]){ CTL_HW, HW_MEMSIZE }, 2, &ram->bytesTotal, &length, NULL, 0) != 0)
return "Failed to read hw.memsize";
mach_msg_type_number_t count = HOST_VM_INFO64_COUNT;
vm_statistics64_data_t vmstat;
if(host_statistics64(mach_host_self(), HOST_VM_INFO64, (host_info64_t) (&vmstat), &count) != KERN_SUCCESS)
return "Failed to read host_statistics64";
// Match what Activity Monitor does: https://github.com/st3fan/osx-10.9/blob/34e34a6a539b5a822cda4074e56a7ced9b57da71/system_cmds-597.1.1/vm_stat.tproj/vm_stat.c#L139
ram->bytesUsed = ram->bytesTotal - ((uint64_t)(vmstat.free_count - vmstat.speculative_count) + vmstat.external_page_count) * instance.state.platform.sysinfo.pageSize;
return NULL;
}I'm not sure why but when I test the above code in my own C program it matches Activity Monitor perfectly. But when I use it in fastfetch the values are slightly off by a bit; this is likely due to how fastfetch handles rounding up/down.
Version used
fastfetch 2.58.0-4 (aarch64)
Bug prevalence
Always
Regression
No
Installation
Built from source
Package manager
No response
Screenshots
No response
Configuration
No response
System information
Features built-in
threads
vulkan
zlib
sqlite3
libzfs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
[ { "type": "Title", "result": { "userName": "macintosh", "fullUserName": "Macintosh", "hostName": "Mac.lan", "homeDir": "/Users/macintosh/", "exePath": "/usr/local/bin/fastfetch", "userShell": "/bin/zsh" }, "stat": 0.008000001311302185 }, { "type": "Separator", "error": "Unsupported for JSON format", "stat": 0.003999998793005943 }, { "type": "OS", "result": { "buildID": "25C56", "codename": "Tahoe", "id": "macos", "idLike": "", "name": "macOS", "prettyName": "macOS Tahoe 26.2 (25C56)", "variant": "", "variantID": "", "version": "26.2", "versionID": "26.2" }, "stat": 0.29400000162422657 }, { "type": "Host", "result": { "family": "Mac14,12", "name": "Mac mini (M2 Pro, 2023, Four Thunderbolt 4 ports)", "version": "", "sku": "", "vendor": "Apple Inc.", "serial": "XJPJXVPXD9", "uuid": "289F3795-B94E-5D05-9A48-FCBCC4DCD5AC" }, "stat": 0.12999999895691872 }, { "type": "BIOS", "result": { "date": "Thu Nov 13 21:45:00 PST 2025", "release": "", "vendor": "Apple Inc.", "version": "13822.61.10", "type": "iBoot" }, "stat": 0.18500000052154064 }, { "type": "Bootmgr", "result": { "name": "iBoot", "firmware": "/System/Library/CoreServices/boot.efi", "order": 0, "secureBoot": true }, "stat": 0.041999999433755875 }, { "type": "Board", "result": { "name": "J474sAP", "vendor": "Apple Inc.", "version": "", "serial": "" }, "stat": 0.04800000041723251 }, { "type": "Chassis", "result": { "type": "Mini PC", "vendor": "Apple Inc.", "version": "", "serial": "" }, "stat": 0.06799999997019768 }, { "type": "Kernel", "result": { "architecture": "arm64", "name": "Darwin", "release": "25.2.0", "version": "Darwin Kernel Version 25.2.0: Tue Nov 18 21:07:05 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T6020", "pageSize": 16384 }, "stat": 0.0020000003278255463 }, { "type": "InitSystem", "result": { "name": "launchd", "exe": "/sbin/launchd", "version": "7.0.0", "pid": 1 }, "stat": 7.087999999523163 }, { "type": "Uptime", "result": { "uptime": 8774680, "bootTime": "2026-01-26T19:09:00.085-0500" }, "stat": 0.4249999988824129 }, { "type": "Loadavg", "result": [ 1.9375, 1.80859375, 1.5263671875 ], "stat": 0.008000001311302185 }, { "type": "Processes", "result": 585, "stat": 0.06799999997019768 }, { "type": "Packages", "result": { "all": 28, "amSystem": 0, "amUser": 0, "apk": 0, "brew": 0, "brewCask": 0, "choco": 0, "dpkg": 0, "emerge": 0, "eopkg": 0, "flatpakSystem": 0, "flatpakUser": 0, "guixSystem": 0, "guixUser": 0, "guixHome": 0, "hpkgSystem": 0, "hpkgUser": 0, "linglong": 0, "mport": 0, "nixDefault": 0, "nixSystem": 0, "nixUser": 0, "opkg": 0, "pacman": 0, "pacstall": 0, "paludis": 0, "pisi": 0, "pkg": 0, "pkgtool": 0, "pkgsrc": 0, "macports": 28, "rpm": 0, "scoopUser": 0, "scoopGlobal": 0, "snap": 0, "soar": 0, "kiss": 0, "sorcery": 0, "winget": 0, "xbps": 0, "pacmanBranch": "" }, "stat": 0.15599999949336052 }, { "type": "Shell", "result": { "exe": "zsh", "exeName": "zsh", "exePath": "/bin/zsh", "pid": 4930, "ppid": 4929, "processName": "zsh", "prettyName": "zsh", "version": "5.9", "tty": 0 }, "stat": 3.3029999993741512 }, { "type": "Editor", "error": "$VISUAL or $EDITOR not set", "stat": 0.005000000819563866 }, { "type": "Display", "result": [ { "id": 3, "name": "CU34G2XP", "primary": true, "output": { "width": 3440, "height": 1440, "refreshRate": 100.0, "drrStatus": null }, "scaled": { "width": 3440, "height": 1440 }, "preferred": { "width": 3440, "height": 1440, "refreshRate": 100.0 }, "physical": { "width": 800, "height": 330 }, "rotation": 0, "bitDepth": 10, "hdrStatus": "Supported", "type": "External", "manufactureDate": { "year": 2024, "week": 22 }, "serial": 4842, "platformApi": "CoreGraphics" } ], "stat": 22.419999999925494 }, { "type": "Brightness", "result": [ { "name": "CU34G2XP", "max": 100.0, "min": 0.0, "current": 70.0, "builtin": false } ], "stat": 62.696000000461936 }, { "type": "Monitor", "error": "Monitor module is an alias of Display module", "stat": 0.003999998793005943 }, { "type": "LM", "error": "Not supported on this platform", "stat": 0.0010000001639127731 }, { "type": "DE", "error": "No DE found", "stat": 0.0030000004917383194 }, { "type": "WM", "result": { "processName": "WindowServer", "prettyName": "Quartz Compositor", "protocolName": "", "pluginName": "", "version": "1.600.0" }, "stat": 0.16499999910593033 }, { "type": "WMTheme", "result": "Multicolor (Light)", "stat": 0.13500000163912773 }, { "type": "Theme", "result": { "theme1": "Liquid Glass", "theme2": "" }, "stat": 0.00299999862909317 }, { "type": "Icons", "error": "Not supported on this platform", "stat": 0.0010000001639127731 }, { "type": "Font", "result": { "display": ".AppleSystemUIFont [System], Helvetica [User]", "fonts": [ ".AppleSystemUIFont", "Helvetica", ".AppleSystemUIFontMonospaced", "Menlo" ] }, "stat": 4.936000000685453 }, { "type": "Cursor", "result": { "theme": "Fill - Black, Outline - White", "size": "32" }, "stat": 0.19500000029802322 }, { "type": "Wallpaper", "error": "All detection methods failed", "stat": 89.02999999932945 }, { "type": "Terminal", "result": { "processName": "Apple_Terminal", "exe": "/System/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal", "exeName": "Terminal", "exePath": "/System/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal", "pid": 640, "ppid": 1, "prettyName": "Apple Terminal", "version": "466", "tty": "" }, "stat": 0.1659999992698431 }, { "type": "TerminalFont", "result": { "font": { "name": "SFMono-Regular", "size": "11", "styles": [], "pretty": "SFMono-Regular (11pt)" }, "fallback": { "name": "", "size": "", "styles": [], "pretty": "" } }, "stat": 22.427000001072884 }, { "type": "TerminalSize", "result": { "columns": 240, "rows": 86, "width": 1680, "height": 1215 }, "stat": 0.054999999701976776 }, { "type": "TerminalTheme", "result": { "fg": { "r": 0, "g": 0, "b": 0, "dark": true }, "bg": { "r": 255, "g": 255, "b": 255, "dark": false } }, "stat": 0.2410000003874302 }, { "type": "CPU", "result": { "cpu": "Apple M2 Pro", "vendor": "Apple", "packages": 1, "cores": { "physical": 10, "logical": 10, "online": 10 }, "frequency": { "base": 0, "max": 3504 }, "coreTypes": [ { "count": 6, "freq": 2 }, { "count": 4, "freq": 1 } ], "temperature": 33.96142450968424, "march": "ARMv8.6-A", "numaNodes": null }, "stat": 6.244999999180436 }, { "type": "CPUCache", "result": { "l1": [ { "size": 196608, "num": 6, "lineSize": 128, "type": "instruction" }, { "size": 131072, "num": 6, "lineSize": 128, "type": "data" }, { "size": 131072, "num": 4, "lineSize": 128, "type": "instruction" }, { "size": 65536, "num": 4, "lineSize": 128, "type": "data" } ], "l2": [ { "size": 16777216, "num": 2, "lineSize": 128, "type": "unified" }, { "size": 4194304, "num": 1, "lineSize": 128, "type": "unified" } ] }, "stat": 0.03700000047683716 }, { "type": "CPUUsage", "result": [ 20.0, 10.0, 25.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], "stat": 201.22399999946356 }, { "type": "GPU", "result": [ { "index": 0, "coreCount": 16, "coreUsage": 0.0, "memory": { "dedicated": { "total": null, "used": null }, "shared": { "total": 26800603136, "used": 252182528 }, "type": null }, "driver": "com.apple.AGXG14X 342.3", "name": "Apple M2 Pro", "temperature": 33.9289665222168, "type": "Integrated", "vendor": "Apple", "platformApi": "Metal 4", "frequency": 1398, "deviceId": 4294968765 } ], "stat": 20.600999999791384 }, { "type": "Memory", "result": { "total": 34359738368, "used": 13994967040 }, "stat": 0.01600000075995922 }, { "type": "PhysicalMemory", "result": [ { "size": 34359738368, "maxSpeed": 0, "runningSpeed": 0, "type": "LPDDR5", "locator": "", "formFactor": "", "vendor": "Hynix", "serial": "", "partNumber": "", "ecc": false } ], "stat": 0.06499999947845936 }, { "type": "Swap", "result": [ { "name": "Encrypted", "used": 0, "total": 0 } ], "stat": 0.006000000983476639 }, { "type": "Disk", "result": [ { "bytes": { "available": 905484234752, "free": 905484234752, "total": 994662584320, "used": 89178349568 }, "files": { "total": 4294141691, "used": 453019 }, "filesystem": "apfs", "mountpoint": "/", "mountFrom": "/dev/disk3s1s1", "name": "Macintosh HD", "volumeType": [ "Regular", "Read-only" ], "createTime": "2025-11-22T08:49:28.000-0500" }, { "bytes": { "available": 905484234752, "free": 905484234752, "total": 994662584320, "used": 89178349568 }, "files": { "total": 253205136, "used": 520248 }, "filesystem": "apfs", "mountpoint": "/System/Volumes/Data", "mountFrom": "/dev/disk3s5", "name": "Data", "volumeType": [ "Hidden" ], "createTime": "2025-03-27T07:30:45.656-0400" }, { "bytes": { "available": 506286080, "free": 506286080, "total": 524288000, "used": 18001920 }, "files": { "total": 4944259, "used": 59 }, "filesystem": "apfs", "mountpoint": "/System/Volumes/Hardware", "mountFrom": "/dev/disk1s3", "name": "Hardware", "volumeType": [ "Hidden" ], "createTime": "2025-04-11T19:02:10.349-0400" }, { "bytes": { "available": 905484275712, "free": 905484275712, "total": 994662584320, "used": 89178308608 }, "files": { "total": 252688215, "used": 2927 }, "filesystem": "apfs", "mountpoint": "/System/Volumes/Preboot", "mountFrom": "/dev/disk3s2", "name": "Preboot", "volumeType": [ "Hidden" ], "createTime": "2025-04-11T19:02:09.072-0400" }, { "bytes": { "available": 905488363520, "free": 905488363520, "total": 994662584320, "used": 89174220800 }, "files": { "total": 252725314, "used": 106 }, "filesystem": "apfs", "mountpoint": "/System/Volumes/Update", "mountFrom": "/dev/disk3s4", "name": "Update", "volumeType": [ "Hidden" ], "createTime": "2025-04-11T19:02:11.357-0400" }, { "bytes": { "available": 905488363520, "free": 905488363520, "total": 994662584320, "used": 89174220800 }, "files": { "total": 252725208, "used": 0 }, "filesystem": "apfs", "mountpoint": "/System/Volumes/VM", "mountFrom": "/dev/disk3s6", "name": "VM", "volumeType": [ "Hidden" ], "createTime": "2025-04-12T18:12:46.114-0400" }, { "bytes": { "available": 506286080, "free": 506286080, "total": 524288000, "used": 18001920 }, "files": { "total": 4944231, "used": 31 }, "filesystem": "apfs", "mountpoint": "/System/Volumes/iSCPreboot", "mountFrom": "/dev/disk1s1", "name": "iSCPreboot", "volumeType": [ "Hidden" ], "createTime": "2025-04-11T19:02:09.889-0400" }, { "bytes": { "available": 506286080, "free": 506286080, "total": 524288000, "used": 18001920 }, "files": { "total": 4944201, "used": 1 }, "filesystem": "apfs", "mountpoint": "/System/Volumes/xarts", "mountFrom": "/dev/disk1s2", "name": "xarts", "volumeType": [ "Hidden" ], "createTime": "2025-04-11T19:02:10.126-0400" } ], "stat": 0.13700000010430813 }, { "type": "Btrfs", "error": "Not supported on this platform", "stat": 0.001999998465180397 }, { "type": "Zpool", "error": "dlopen(libzfs.dylib) failed", "stat": 1.805000001564622 }, { "type": "Battery", "result": [], "stat": 0.13899999856948853 }, { "type": "PowerAdapter", "result": [], "stat": 0.22300000116229057 }, { "type": "Player", "error": "Player module is an alias of Media module", "stat": 0.0010000001639127731 }, { "type": "Media", "error": "No media found", "stat": 42.20899999886751 }, { "type": "DateTime", "result": "2026-01-26T21:35:15.259-0500", "stat": 0.005000000819563866 }, { "type": "Locale", "result": "en_US.UTF-8", "stat": 0.001999998465180397 }, { "type": "Vulkan", "result": { "apiVersion": "1.1.323", "conformanceVersion": "1.4", "driver": "MoltenVK [1.4.0]", "gpus": [ { "type": "Integrated", "vendor": "Apple", "name": "Apple M2 Pro", "driver": "1.4.0", "platformApi": "Vulkan 1.1.323", "deviceId": 436339208, "memory": { "dedicated": { "total": 0, "used": null }, "shared": { "total": 34359738368, "used": null } }, "deviceId": 436339208 } ] }, "stat": 2.084000000730157 }, { "type": "OpenGL", "result": { "version": "4.1 Metal - 90.5", "renderer": "Apple M2 Pro", "vendor": "Apple", "slv": "4.10", "library": "CGL 1.2" }, "stat": 8.976999999955297 }, { "type": "OpenCL", "result": { "version": "1.2 (Nov 8 2025 19:10:43)", "name": "Apple", "vendor": "Apple", "gpus": [ { "type": "Integrated", "vendor": "Apple", "name": "Apple M2 Pro", "driver": "1.0", "platformApi": "OpenCL 1.2", "coreCount": 16, "frequency": 1000, "memory": { "dedicated": { "total": null, "used": null }, "shared": { "total": 26800603136, "used": null } }, "deviceId": 16940800 } ] }, "stat": 0.02800000086426735 }, { "type": "Users", "result": [ { "name": "macintosh", "hostName": "", "sessionName": "ttys000", "clientIp": "", "loginTime": "2026-01-26T21:35:07.110-0500" } ], "stat": 0.08499999903142452 }, { "type": "Bluetooth", "result": [], "stat": 31.498999999836087 }, { "type": "BluetoothRadio", "result": [ { "name": "macintosh", "address": "00:C5:85:00:FA:54", "lmpVersion": -11, "lmpSubversion": null, "vendor": "Apple", "enabled": true, "discoverable": false, "connectable": true } ], "stat": 61.52500000037253 }, { "type": "Sound", "result": [ { "active": true, "main": false, "volume": null, "name": "CU34G2XP", "identifier": "05E306B2-0000-0000-1622-010380502178", "platformApi": "Core Audio" }, { "active": true, "main": true, "volume": 0, "name": "Mac mini Speakers", "identifier": "BuiltInSpeakerDevice", "platformApi": "Core Audio" } ], "stat": 26.94899999909103 }, { "type": "Camera", "result": [ { "name": "OBS Virtual Camera", "vendor": "OBS Project", "colorSpace": "sRGB", "id": "7626645E-4425-469E-9D8B-97E0FA59AC75", "width": 1920, "height": 1080 } ], "stat": 21.213000001385808 }, { "type": "Gamepad", "result": [], "stat": 0.10699999891221523 }, { "type": "Mouse", "result": [ { "serial": "", "name": "USB Optical Mouse", "ignored": false } ], "stat": 4.532999999821186 }, { "type": "Keyboard", "result": [ { "serial": "", "name": "USB Keyboard", "ignored": false } ], "stat": 3.16300000064075 }, { "type": "Weather", "error": "poll() timeout", "stat": 1001.3090000003576 }, { "type": "NetIO", "result": [ { "name": "en1", "defaultRoute": true, "txBytes": 993, "rxBytes": 1299, "txPackets": 11, "rxPackets": 10, "rxErrors": 0, "txErrors": 0, "rxDrops": 0, "txDrops": 0 } ], "stat": 0.08299999870359898 }, { "type": "DiskIO", "result": [ { "name": "APPLE SSD AP1024Z Media", "devPath": "/dev/disk0", "bytesRead": 0, "bytesWritten": 1798144, "readCount": 0, "writeCount": 196 } ], "stat": 1.3160000015050173 }, { "type": "PhysicalDisk", "result": [ { "name": "APPLE SSD AP1024Z Media", "devPath": "/dev/disk0", "interconnect": "Apple Fabric", "kind": "SSD", "size": 1000555581440, "serial": "0ba01f12c0d51c16", "removable": false, "readOnly": false, "revision": "555", "temperature": 27.0 } ], "stat": 5.933999998494983 }, { "type": "TPM", "result": { "version": "2.0", "description": "Apple Silicon Security" }, "stat": 0.005000000819563866 }, { "type": "Version", "result": { "projectName": "fastfetch", "sysName": "macOS", "architecture": "aarch64", "version": "2.58.0", "versionGit": "2.58.0-4-g4a581039", "cmakeBuiltType": "RelWithDebInfo", "compileTime": "Jan 26 2026, 21:32:57", "compiler": "Apple clang 17.0.0 (17000603)", "debugMode": false, "libc": "libSystem 1356.0.0" }, "stat": 0.005000000819563866 }, { "type": "Break", "error": "Unsupported for JSON format", "stat": 0.00299999862909317 }, { "type": "Colors", "error": "Unsupported for JSON format", "stat": 0.0020000003278255463 } ]