Getting ESX and ESXi Memory Info

With a vSphere Client, you can easily check the memory information of a host, either ESX or ESXi. To get that, you click on a host from the inventory tree, and then configuration tab. From the left side Hardware section of the configuration page, you click Memory and see a pane displaying the memory info as follows:

Lost VMs or Containers? Too Many Consoles? Too Slow GUI? Time to learn how to "Google" and manage your VMware and clouds in a fast and secure HTML5 App.

Note that if you have chosen a ESXi host, you won’t see the Service Console part because there is no console OS any more in ESXi. BTW, VMware wants you to migrate from ESX to ESXi and here is a link with helps.

This seemingly easy information is actually not easy to get. At first glance, it should be in the config property of HostSystem (managed object representing an ESX or ESXi). The config property has a sub property called systemResources, typed as HostSystemResourceInfo. But you will get null for the systemResources property most, if not all, of the time, as reported in VI Java API forum.

Interestingly enough, HostSystem has a systemResources property in peer to the config property as well. Luckily, it’s not null so you can dig down for something. Still, with 3 sub properties of complex types included, how to get the memory from the data object?

Here are the steps to collect and calculate the numbers:

Get the total memory

You will use the following property path for the number in bytes and then divide it by 1024*1024 for a number in MB.


If you use VI Java API, you can do like this:

double totalMemInMB = host.getSummary().getHardware().getMemorySize / (1024*1024);

Get virtual machines’ memory

This number is not dynamic reflecting the memory usage by virtual machines but rather the memory reserved for virtual machines. With this in mind, you can get it as follows:


Notice that it is not divided by 1024*1024. It turns out the number you get as reservation is in MB already.

Get Service Console memory

Again, it’s only for ESX as ESXi does not have console OS therefore not relevant. You can get it as follows:


Get the system memory

Naturally you would think of the systemResources property again. You can indeed find the recursive resource allocations for “host/system” along with others like “host/idle,” “host/vim,” and “host/user.” You can of course dig down these data object and may calculate a number with a sophisticated algorithm.

It turned out it’s not necessarily as complicated as we think if we notice the relationships of these numbers: Total = System + VM + ConsoleOS. With this in mind, the system memory could be as simple as deductions like this:

System = total – VM – ConsoleOS

With these steps you can get the same numbers as vSphere Client.

This entry was posted in vSphere API and tagged , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.


  1. Nikita
    Posted February 5, 2011 at 9:08 am | Permalink

    Hi, Steve
    Unfortunately, vSphere has some issues with memory size dislplaying. I’ve found this situation in my project when I tried to get memory info from ESX and recived null value. vSphere Client have also dislpayed zero value of memory and CPU consumption.
    So my recomendation is to check recived value for null.

  2. Posted February 5, 2011 at 11:47 am | Permalink

    Hi Nikita,
    Thanks for sharing your experience. Checking null is always good. Can you provide more specifics on your environment and in which condition the issue happens? Thanks!

  3. vishal
    Posted February 9, 2011 at 1:46 am | Permalink


    Is there a c++ or c package that is simillar to VIJava?

    Please let me know

  4. Posted February 9, 2011 at 7:34 pm | Permalink

    Hi Vishal,

    There is an open source project created by Andrew Kutz in C#. I am not aware of C++ or C implementation that matches vijava. If you find one, please let me know as well.


  5. vishal
    Posted February 11, 2011 at 10:46 am | Permalink


    is json output supported by the webservices?


  6. Posted February 11, 2011 at 11:06 am | Permalink

    Not for vSphere Web Services as I know. For Web Services in general, it’s possible. Either XML or JSON, it’s just format for messages.


  7. kim
    Posted February 11, 2013 at 6:19 am | Permalink

    what are the attributes of memeory and cpu?how to get them using vi java api?

  8. Samy
    Posted January 8, 2014 at 1:04 am | Permalink

    Hi steve,

  9. Samy
    Posted January 8, 2014 at 1:06 am | Permalink

    hi steve,

    i want to get the hardware information where host is installed through vijava.
    can you please help me???


Post a Comment

Your email is never published nor shared. Required fields are marked *


You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


    My company has created products like vSearch ("Super vCenter"), vijavaNG APIs, EAM APIs, ICE tool. We also help clients with virtualization and cloud computing on customized development, training. Should you, or someone you know, need these products and services, please feel free to contact me: steve __AT__

    Me: Steve Jin, VMware vExpert who authored the VMware VI and vSphere SDK by Prentice Hall, and created the de factor open source vSphere Java API while working at VMware engineering. Companies like Cisco, EMC, NetApp, HP, Dell, VMware, are among the users of the API and other tools I developed for their products, internal IT orchestration, and test automation.