<p dir="ltr">Ok. So that's why I was getting 1 GB as a result. </p>
<p dir="ltr">So is there any way I can get memory in used programmatically? <br>
I mean without going inside guest domain. </p>
<div class="gmail_quote">On Aug 5, 2016 5:42 PM, "Andrea Bolognani" <<a href="mailto:abologna@redhat.com">abologna@redhat.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Thu, 2016-08-04 at 20:02 +0500, Aleem Akhtar wrote:<br>
> <br>
> I am trying to get stats of Domains running under XEN hypervisor.<br>
> I used Libvirt function for this purpose. I am trying to understand<br>
> output for Memory. Domain running is Fedora-22 with 1GB Ram. Here is my<br>
> code<br>
> <br>
> y = virDomainGetInfo(allDomain, &info);<br>
> if (y == -1)<br>
>     printf("Errorl\n");<br>
> else {<br>
>     printf("Max Memory: %lu\n", info.maxMem);<br>
>     printf("Memory: %lu", info.memory);<br>
> }<br>
> <br>
> I get output as<br>
> <br>
> Max Memory: 1048576<br>
> Memory: 1048576<br>
> <br>
> Now, as per Libvirt API, info.memory should return the memory in KBytes<br>
> used by the domain. My Question is, if info.memory returns memory used<br>
> and my domain is using complete 100% of Max Memory or not? Also I tried<br>
> to create Domain with memory varying from 128MB to 2GB with same effect.<br>
> I also tried to run some applications in Domain but Memory usage return<br>
> by given function does not change. Any help or guidance will be much<br>
> appreciated.<br>
<br>
The relevant virDomainInfo field is described as<br>
<br>
  /* the memory in KBytes used by the domain */<br>
  unsigned long memory;<br>
<br>
but in this context, "used by" really means "available to".<br>
<br>
So the output above tells you that your Fedora guest has<br>
1 GB of memory available; how much of that memory is actually<br>
being used by the guest OS is something that you can find out<br>
by running top inside the guest.<br>
<br>
-- <br>
Andrea Bolognani / Red Hat / Virtualization<br>
</blockquote></div>