I'm trying to get the Total Ram in Java using Sigar library, I do the following
return String.valueOf(sigar.getMem().getRam());
My total RAM is 4GB, so I was expecting 4
or 4.00
but the result is 4008
.
I tried the following:
long x = sigar.getMem().getTotal();
final String[] units = new String[] { "B", "KB", "MB", "GB", "TB" };
int digitGroups = (int) (Math.log10(x) / Math.log10(1024));
return new DecimalFormat("#,##0.##")
.format(x / Math.pow(1024, digitGroups)) + " " + units[digitGroups];
but still I'm having the result of 3.91 GB
.
Any Idea?
You probably have 3.91 physically available GigaBytes, and the math from Sigar is correct.
Check if your BIOS is reserving some RAM for the integrated graphics device or some other devilry.