Overview
Gopsutil provides platform-specific extended memory information beyond the standardVirtualMemoryStat struct. These extensions offer deeper insights into memory management on Linux and Windows systems.
Linux Extended Memory
Linux systems have access to additional memory statistics through theExLinux interface.
ExVirtualMemory Struct
Fields
ActiveFile
- Type:
uint64 - Description: File-backed pages that are actively used (hot file cache)
- Source:
/proc/meminfoActive(file) - Use case: Pages recently accessed from files, likely to be accessed again
InactiveFile
- Type:
uint64 - Description: File-backed pages that are not actively used (cold file cache)
- Source:
/proc/meminfoInactive(file) - Use case: Pages that can be reclaimed when memory pressure occurs
ActiveAnon
- Type:
uint64 - Description: Anonymous pages that are actively used (process memory, not file-backed)
- Source:
/proc/meminfoActive(anon) - Use case: Recently used process heap, stack, and anonymous mmap regions
InactiveAnon
- Type:
uint64 - Description: Anonymous pages that are not actively used
- Source:
/proc/meminfoInactive(anon) - Use case: Process memory that hasn’t been accessed recently, candidates for swapping
Unevictable
- Type:
uint64 - Description: Memory that cannot be evicted (mlock’d pages, ramdisks)
- Source:
/proc/meminfoUnevictable - Use case: Pages locked in memory by
mlock(), SHM_LOCK, or other mechanisms
Percpu
- Type:
uint64 - Description: Memory allocated for per-CPU structures
- Source:
/proc/meminfoPercpu - Use case: Kernel per-CPU data structures for performance optimization
KernelStack
- Type:
uint64 - Description: Memory used by kernel stacks
- Source:
/proc/meminfoKernelStack - Use case: Stack space for kernel threads and syscall execution
Methods
String
Usage
TheExLinux type provides access to extended Linux memory statistics:
With Context
Windows Extended Memory
Windows systems have access to additional memory information through theExWindows interface.
ExVirtualMemory Struct
Fields
CommitLimit
- Type:
uint64 - Description: Maximum amount of memory the system can commit (physical RAM + page files)
- Source: Windows API
GetPerformanceInfo-commitLimit * pageSize - Reference: PERFORMANCE_INFORMATION structure
CommitTotal
- Type:
uint64 - Description: Amount of memory currently committed by the system
- Source: Windows API
GetPerformanceInfo-commitTotal * pageSize - Note: Includes both physical RAM and page file usage
VirtualTotal
- Type:
uint64 - Description: Total size of user-mode virtual address space
- Source: Windows API
GlobalMemoryStatusEx-ullTotalVirtual - Reference: MEMORYSTATUSEX structure
- Typical value: 2 GB on 32-bit, 8 TB on 64-bit Windows
VirtualAvail
- Type:
uint64 - Description: Available size of user-mode virtual address space
- Source: Windows API
GlobalMemoryStatusEx-ullAvailVirtual - Use case: Unreserved and uncommitted memory in the user-mode address space
PhysTotal
- Type:
uint64 - Description: Total physical RAM installed
- Source: Windows API
GlobalMemoryStatusEx-ullTotalPhys
PhysAvail
- Type:
uint64 - Description: Available physical RAM
- Source: Windows API
GlobalMemoryStatusEx-ullAvailPhys
PageFileTotal
- Type:
uint64 - Description: Total size of page file (swap)
- Source: Windows API
GlobalMemoryStatusEx-ullTotalPageFile - Note: Includes physical RAM + page file total
PageFileAvail
- Type:
uint64 - Description: Available page file space
- Source: Windows API
GlobalMemoryStatusEx-ullAvailPageFile
Usage
TheExWindows type provides access to extended Windows memory statistics:
Platform Detection
Since extended functions are platform-specific, use runtime checks:Use Cases
Linux Memory Analysis
Cache Analysis
Distinguish between active and inactive file cache to understand memory reclaim potential
Swap Candidates
Identify inactive anonymous memory that’s likely to be swapped
Locked Memory
Monitor unevictable pages from real-time processes or shared memory
Kernel Overhead
Track kernel stack and per-CPU memory usage
Windows Memory Analysis
Commit Charge
Monitor commit charge to prevent out-of-memory conditions
Virtual Address Space
Track address space exhaustion on 32-bit applications
Page File Usage
Monitor page file usage and availability
Physical vs Virtual
Distinguish between physical RAM and virtual memory usage
References
Linux
Windows
See Also
- Virtual Memory - Standard memory statistics
- Memory Package Overview - Package introduction
- Swap Memory - Swap space statistics