[virt-tools-list] How does the memory usage calculated?

张强 zhangqiang at meizu.com
Wed Nov 18 13:04:32 UTC 2015


Hi all,
I’m studying the source code, and I saw this in domain.py around line 164:
…
        curmem = stats['rss']
        totalmem = stats['actual']
except libvirt.libvirtError, err:
    logging.error("Error reading mem stats: %s", err)

pcentCurrMem = curmem * 100.0 / totalmem
pcentCurrMem = max(0.0, min(pcentCurrMem, 100.0))
…

But using this algorithm, I’m always getting results that are greater than 100:
>>> dom.memoryStats()
{'actual': 16777216L, 'rss': 17062900L}

17062900 * 100 / 16777216 = 101.7028…

Is this normal?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20151118/498cce87/attachment.htm>


More information about the virt-tools-list mailing list