Libvirt Functions
PHP Manual


(php-libvirt 0.3)

libvirt_domain_memory_statsprovide memory statistics for the domain.


array libvirt_domain_memory_stats ( resource $domain [, integer $flags= 0 ] )

This function provides memory statistics for the domain. Up to VIR_DOMAIN_MEMORY_STAT_NR elements will be populated in the returned array with memory statistics from the domain. Only statistics supported by the domain, the driver, and this version of libvirt will be returned. The array is indexed by the numerical values of appropriate constants.

Possible members of the array returned by libvirt_domain_memory_stats
VIR_DOMAIN_MEMORY_STAT_SWAP_INThe total amount of data read from swap space (in kb)
VIR_DOMAIN_MEMORY_STAT_SWAP_OUTThe total amount of memory written out to swap space (in kb)
VIR_DOMAIN_MEMORY_STAT_MAJOR_FAULTThe number of page faults that required disk IO to service.
VIR_DOMAIN_MEMORY_STAT_MINOR_FAULTThe number of page faults serviced without disk IO.
VIR_DOMAIN_MEMORY_STAT_UNUSEDThe amount of memory which is not being used for any purpose (in kb).
VIR_DOMAIN_MEMORY_STAT_AVAILABLEThe total amount of memory available to the domain's OS (in kb).

Note: Warning
This is the first implementation of this function in phplibvirt. There are some unsolved issues regarding integer ranges between PHP and Libvirt. We may change the beahviour of this function in future.

Note: Libvirt version
This function has been added to Libvirt in version 0.7.5. You need this or newer version of Libvirt to be able to use this function.



Domain resource of domain to get memory stats.


unused, always pass 0 (or ommit the parameter as 0 is default value

Return Values

Array containig Up to VIR_DOMAIN_MEMORY_STAT_NR elements with statistics.

See Also

Libvirt Functions
PHP Manual