-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
6
-
x86
-
windows_xp
FULL PRODUCT VERSION :
java version "1.6.0_04"
Java(TM) SE Runtime Environment (build 1.6.0_04-b12)
Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Windows XP Professional Service Pack 2
A DESCRIPTION OF THE PROBLEM :
Attempting to cast a nonNumber object to Number results in a ClassCastException, which results in a sizeable memory leak if there is a high frequency of such exceptions,
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run the attached test program and monitor the Memory Usage using the Task Manager or Process Explorer. It will grow considerably using Java 6 (any release) or Java 7, but not with Java 5.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Both the Java heap and the overall memory usage snould remain constant, once the JVM is fully operational.
ACTUAL -
The memory size grows from 8mb to over 600mb when running the test program.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
None
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class TestMe {
public static void main(String args[]) {
long numExceptions = 0L;
String str = "";
Object o = str;
for (int i = 0; i < 10000000; i++) {
try {
double x = ((Number)o).doubleValue();
} catch (ClassCastException ex) {
numExceptions++;
}
}
System.out.println("numExceptions="+numExceptions);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
public class TestMe {
public static void main(String args[]) {
long numExceptions = 0L;
String str = "";
Object o = str;
for (int i = 0; i < 10000000; i++) {
try {
if (o instanceof Number) {
double x = ((Number)o).doubleValue();
}
} catch (ClassCastException ex) {
numExceptions++;
}
}
System.out.println("numExceptions="+numExceptions);
}
}
However, there may be other cases where Exception objects are being created for which sucn a workaround is not sufficient.
Release Regression From : 5.0u12
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.
java version "1.6.0_04"
Java(TM) SE Runtime Environment (build 1.6.0_04-b12)
Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Windows XP Professional Service Pack 2
A DESCRIPTION OF THE PROBLEM :
Attempting to cast a nonNumber object to Number results in a ClassCastException, which results in a sizeable memory leak if there is a high frequency of such exceptions,
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run the attached test program and monitor the Memory Usage using the Task Manager or Process Explorer. It will grow considerably using Java 6 (any release) or Java 7, but not with Java 5.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Both the Java heap and the overall memory usage snould remain constant, once the JVM is fully operational.
ACTUAL -
The memory size grows from 8mb to over 600mb when running the test program.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
None
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class TestMe {
public static void main(String args[]) {
long numExceptions = 0L;
String str = "";
Object o = str;
for (int i = 0; i < 10000000; i++) {
try {
double x = ((Number)o).doubleValue();
} catch (ClassCastException ex) {
numExceptions++;
}
}
System.out.println("numExceptions="+numExceptions);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
public class TestMe {
public static void main(String args[]) {
long numExceptions = 0L;
String str = "";
Object o = str;
for (int i = 0; i < 10000000; i++) {
try {
if (o instanceof Number) {
double x = ((Number)o).doubleValue();
}
} catch (ClassCastException ex) {
numExceptions++;
}
}
System.out.println("numExceptions="+numExceptions);
}
}
However, there may be other cases where Exception objects are being created for which sucn a workaround is not sufficient.
Release Regression From : 5.0u12
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.