United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6853676 : OperatingSystemMXBean.TotalPhysicalMemorySize has incorrect value

Details
Type:
Bug
Submit Date:
2009-06-22
Status:
Resolved
Updated Date:
2013-04-30
Project Name:
JDK
Resolved Date:
2012-09-11
Component:
core-svc
OS:
windows_vista,solaris_8
Sub-Component:
java.lang.management
CPU:
x86,generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
6,6u10
Fixed Versions:

Related Reports
Duplicate:

Sub Tasks

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
                                     
2012-09-04
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.
                                     
2012-07-23
SUGGESTED FIX

Patch from OpenJDK bugzilla attached.
                                     
2012-07-23



Hardware and Software, Engineered to Work Together