Overview
TheVirtualMemoryStat struct contains comprehensive RAM usage statistics. The Total, Available, and Used fields provide human-consumable byte counts that work consistently across all platforms. Additional fields contain platform-specific kernel values.
Struct Definition
Fields
Cross-Platform Fields
These fields are available and meaningful on all supported platforms.Total
- Type:
uint64 - Description: Total amount of physical RAM installed on the system in bytes
- Example:
16777216000(16 GB)
Available
- Type:
uint64 - Description: RAM available for programs to allocate. This is the best estimate of memory that can be used without swapping
- Computed from: Platform-specific kernel values
- Use case: Use this to determine if the system has enough memory for new processes
Used
- Type:
uint64 - Description: RAM currently in use by programs
- Computed from: Platform-specific kernel values
- Note: Does not include all memory, as some may be reclaimable (like caches)
UsedPercent
- Type:
float64 - Description: Percentage of RAM in use (0.0 to 100.0)
- Computed from: Platform-specific kernel values
- Example:
67.5means 67.5% of RAM is in use
Free
- Type:
uint64 - Description: Kernel’s notion of completely free memory (unused RAM chips)
- Important: This is NOT the amount of memory available for use. Use
Availableinstead for human consumption - Note: On modern systems, this value is often very low because the kernel uses free memory for caching
macOS / BSD Specific Fields
These fields are populated on macOS and BSD systems, zero on other platforms.Active
- Type:
uint64 - Description: Memory recently accessed and likely to be accessed again
- Platform: macOS, FreeBSD, OpenBSD
- Reference: Mac memory types
Inactive
- Type:
uint64 - Description: Memory not recently used but still retained in RAM (can be quickly paged back in)
- Platform: macOS, FreeBSD, OpenBSD
Wired
- Type:
uint64 - Description: Memory that must stay in RAM and cannot be paged out (kernel code, core system structures)
- Platform: macOS, FreeBSD, OpenBSD
FreeBSD Specific Fields
Laundry
- Type:
uint64 - Description: Memory in the laundry queue waiting to be cleaned (dirty pages to be written out)
- Platform: FreeBSD only
- Reference: FreeBSD patch D8467
Linux Specific Fields
These fields are populated on Linux systems, zero on other platforms. Values typically come from/proc/meminfo.
Buffers
- Type:
uint64 - Description: Memory used for file buffers
- Source:
/proc/meminfoBuffers field
Cached
- Type:
uint64 - Description: Memory used for page cache and slabs that can be reclaimed
- Source:
/proc/meminfoCached field
WriteBack
- Type:
uint64 - Description: Memory waiting to be written back to disk
- Source:
/proc/meminfoWriteback field
Dirty
- Type:
uint64 - Description: Memory waiting to be written to disk (modified pages)
- Source:
/proc/meminfoDirty field
WriteBackTmp
- Type:
uint64 - Description: Temporary writeback memory (FUSE filesystems)
- Source:
/proc/meminfoWritebackTmp field
Shared
- Type:
uint64 - Description: Memory used by shared memory segments (tmpfs, shared libraries)
- Source:
/proc/meminfoShmem field
Slab
- Type:
uint64 - Description: In-kernel data structures cache
- Source:
/proc/meminfoSlab field
Sreclaimable
- Type:
uint64 - Description: Part of Slab that can be reclaimed (caches)
- Source:
/proc/meminfoSReclaimable field
Sunreclaim
- Type:
uint64 - Description: Part of Slab that cannot be reclaimed
- Source:
/proc/meminfoSUnreclaim field
PageTables
- Type:
uint64 - Description: Memory used by page tables
- Source:
/proc/meminfoPageTables field
SwapCached
- Type:
uint64 - Description: Memory that was swapped out but is now back in RAM (but still also in swap)
- Source:
/proc/meminfoSwapCached field
CommitLimit
- Type:
uint64 - Description: Total memory that can be allocated, based on overcommit settings
- Source:
/proc/meminfoCommitLimit field - Reference: Overcommit accounting
CommittedAS
- Type:
uint64 - Description: Amount of memory presently allocated on the system (committed)
- Source:
/proc/meminfoCommitted_AS field - Note: Can exceed physical RAM due to overcommit
HighTotal
- Type:
uint64 - Description: Total high memory (above ~860MB on 32-bit systems)
- Source:
/proc/meminfoHighTotal field - Note: Only relevant on 32-bit systems
HighFree
- Type:
uint64 - Description: Free high memory
- Source:
/proc/meminfoHighFree field
LowTotal
- Type:
uint64 - Description: Total low memory (below ~860MB on 32-bit systems)
- Source:
/proc/meminfoLowTotal field
LowFree
- Type:
uint64 - Description: Free low memory
- Source:
/proc/meminfoLowFree field
SwapTotal
- Type:
uint64 - Description: Total swap space size
- Source:
/proc/meminfoSwapTotal field
SwapFree
- Type:
uint64 - Description: Free swap space
- Source:
/proc/meminfoSwapFree field
Mapped
- Type:
uint64 - Description: Memory mapped files (mmap)
- Source:
/proc/meminfoMapped field
VmallocTotal
- Type:
uint64 - Description: Total size of vmalloc memory area
- Source:
/proc/meminfoVmallocTotal field
VmallocUsed
- Type:
uint64 - Description: Used vmalloc area
- Source:
/proc/meminfoVmallocUsed field
VmallocChunk
- Type:
uint64 - Description: Largest contiguous block of vmalloc area
- Source:
/proc/meminfoVmallocChunk field
HugePagesTotal
- Type:
uint64 - Description: Total number of huge pages
- Source:
/proc/meminfoHugePages_Total field - Reference: Transparent Huge Pages
HugePagesFree
- Type:
uint64 - Description: Free huge pages
- Source:
/proc/meminfoHugePages_Free field
HugePagesRsvd
- Type:
uint64 - Description: Reserved huge pages
- Source:
/proc/meminfoHugePages_Rsvd field
HugePagesSurp
- Type:
uint64 - Description: Surplus huge pages
- Source:
/proc/meminfoHugePages_Surp field
HugePageSize
- Type:
uint64 - Description: Size of one huge page in bytes
- Source:
/proc/meminfoHugepagesize field - Typical value:
2097152(2 MB) or1073741824(1 GB)
AnonHugePages
- Type:
uint64 - Description: Anonymous huge pages (non-file backed)
- Source:
/proc/meminfoAnonHugePages field
Methods
String
Usage Example
Platform References
Linux Memory Stats
Kernel documentation for /proc/meminfo
Linux Overcommit
Virtual memory overcommit accounting
Transparent Huge Pages
Linux transparent huge pages documentation
macOS Memory Types
Understanding macOS memory categories
See Also
- Swap Memory - Swap space statistics
- Platform-Specific Extensions - Additional Linux/Windows memory info
- Memory Package Overview - Package introduction and main functions