JDK-6853676 : OperatingSystemMXBean.TotalPhysicalMemorySize has incorrect value
  • Type: Bug
  • Component: core-svc
  • Sub-Component: java.lang.management
  • Affected Version: 6,6u10
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_8,windows_vista
  • CPU: generic,x86
  • Submitted: 2009-06-22
  • Updated: 2013-04-30
  • Resolved: 2012-09-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8 b56Fixed
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.6.0_10"
Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode, sharing)

java version "1.7.0-ea-fastdebug"
Java(TM) SE Runtime Environment (build 1.7.0-ea-fastdebug-b58)
Java HotSpot(TM) Client VM (build 16.0-b02-fastdebug, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Windows XP 64-Bit
Microsoft Windows [Version 5.2.3790]


EXTRA RELEVANT SYSTEM CONFIGURATION :
there should be more than 4G of RAM

A DESCRIPTION OF THE PROBLEM :
Such properties of com.sun.management.OperatingSystemMXBean as
  TotalSwapSpaceSize
FreeSwapSpaceSize
  TotalPhysicalMemorySize
FreePhysicalMemorySize
have incorrect values (namely 4294967295 = 0xffffffff) when there is 32bit jre and there are more than 4G of RAM.
Note: 64bit jre shows correct values.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
something like
  TotalSwapSpaceSize         364c45000
FreeSwapSpaceSize          2e28f6000
  TotalPhysicalMemorySize    1ffecf000
FreePhysicalMemorySize     168295000

ACTUAL -
  TotalSwapSpaceSize         ffffffff
FreeSwapSpaceSize          ffffffff
  TotalPhysicalMemorySize    ffffffff
FreePhysicalMemorySize     ffffffff


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.lang.management.ManagementFactory;
import com.sun.management.OperatingSystemMXBean;

public class Main {
	public static void main(String... args) {
		OperatingSystemMXBean bean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
		System.out.println("TotalSwapSpaceSize         " + Long.toHexString(bean.getTotalSwapSpaceSize()));
		System.out.println("FreeSwapSpaceSize          " + Long.toHexString(bean.getFreeSwapSpaceSize()));
		System.out.println("TotalPhysicalMemorySize    " + Long.toHexString(bean.getTotalPhysicalMemorySize()));
		System.out.println("FreePhysicalMemorySize     " + Long.toHexString(bean.getFreePhysicalMemorySize()));
	}
}

---------- END SOURCE ----------

Comments
EVALUATION ok
04-09-2012

SUGGESTED FIX Patch from OpenJDK bugzilla attached.
23-07-2012

PUBLIC COMMENTS Comment copied from http://bugs.openjdk.java.net/show_bug.cgi?id=100077#c0 Description From Dmytro Sheyko 2009-06-19 06:59:37 PDT Incident Review ID: 1545234 Problem Description ------------------- Such properties of com.sun.management.OperatingSystemMXBean as TotalSwapSpaceSize FreeSwapSpaceSize TotalPhysicalMemorySize FreePhysicalMemorySize have incorrect values (namely 4294967295 = 0xffffffff) when there is 32bit jre and there are more than 4G of RAM. Note: 64bit jre shows correct values. Fix Description --------------- According to http://msdn.microsoft.com/en-us/library/aa366586(VS.85).aspx GlobalMemoryStatus can return incorrect information due to overflow and function GlobalMemoryStatusEx is suggested to use instead.
23-07-2012