-
Bug
-
Resolution: Won't Fix
-
P3
-
None
-
7u51, 9
-
x86_64
-
linux
FULL PRODUCT VERSION :
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux hpslim.skynet 3.2.0-58-generic #88-Ubuntu SMP Tue Dec 3 17:37:58 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
I have a stress test case that shows that the field sun.misc.Launcher$AppClassLoader.parallelLockMap grows until "java.lang.OutOfMemoryError: Java heap space" happens, this error does not happen on version 1.6.0_27
REGRESSION. Last worked in version 6u43
ADDITIONAL REGRESSION INFORMATION:
java version "1.6.0_27"
OpenJDK Runtime Environment (IcedTea6 1.12.6) (6b27-1.12.6-1ubuntu0.12.04.4)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
java -ea -XX:MaxPermSize=30m -Xms8m -Xmx64m -XX:+HeapDumpOnOutOfMemoryError test01
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
on 1.6.0_27 the program cleanly exit with "all done" message
ACTUAL -
java.lang.OutOfMemoryError: Java heap space
Dumping heap to java_pid27708.hprof ...
Heap dump file created [87922226 bytes in 0.956 secs]
Java heap space
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.OutOfMemoryError: Java heap space
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.commons.GeneratorAdapter;
import org.objectweb.asm.commons.Method;
import java.lang.reflect.Constructor;
public class test01 {
void doit(String[] args) throws Exception {
test01classmaker cm = new test01classmaker();
ClassLoader thiscl = getClass().getClassLoader();
test01cl clsloader = new test01cl(thiscl, cm);
for (int i=0; i<1000000; i++) {
String className = String.format("Class%04d", i);
clsloader.loadClass(className);
if ((i % 1000) == 0) {
/* discard old class loader */
clsloader = new test01cl(thiscl, cm);
}
}
}
public static void main(String[] args) throws Exception {
try {
new test01().doit(args);
} catch (OutOfMemoryError e) {
System.out.println(e.getMessage());
System.exit(1);
}
System.out.println("all done");
}
public String greeting() {
return "";
}
}
class test01classmaker implements Opcodes {
byte[] makeClass(String className) {
String superName = "test01";
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES + ClassWriter.COMPUTE_MAXS);
cw.visit(V1_6, ACC_PUBLIC, className, null, superName, null);
MethodVisitor mw = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
mw.visitVarInsn(ALOAD, 0);
mw.visitMethodInsn(INVOKESPECIAL, superName, "<init>", "()V");
mw.visitInsn(RETURN);
mw.visitMaxs(0,0);
mw.visitEnd();
mw = cw.visitMethod(ACC_PUBLIC, "greeting", "()Ljava/lang/String;", null, null);
mw.visitLdcInsn(String.format("hello world! (from %s)", className));
mw.visitInsn(ARETURN);
mw.visitMaxs(0,0);
mw.visitEnd();
cw.visitEnd();
return cw.toByteArray();
}
}
class test01cl extends ClassLoader {
test01classmaker cm;
protected test01cl(ClassLoader parent, test01classmaker cm) {
super(parent);
this.cm = cm;
}
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
Class<?> c;
if (name.startsWith("Class") && Integer.parseInt(name.substring(5)) >= 0) {
byte[] code = cm.makeClass(name);
c = defineClass(name, code, 0, code.length);
} else {
c = super.findClass(name);
}
return c;
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
no known workaround
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux hpslim.skynet 3.2.0-58-generic #88-Ubuntu SMP Tue Dec 3 17:37:58 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
I have a stress test case that shows that the field sun.misc.Launcher$AppClassLoader.parallelLockMap grows until "java.lang.OutOfMemoryError: Java heap space" happens, this error does not happen on version 1.6.0_27
REGRESSION. Last worked in version 6u43
ADDITIONAL REGRESSION INFORMATION:
java version "1.6.0_27"
OpenJDK Runtime Environment (IcedTea6 1.12.6) (6b27-1.12.6-1ubuntu0.12.04.4)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
java -ea -XX:MaxPermSize=30m -Xms8m -Xmx64m -XX:+HeapDumpOnOutOfMemoryError test01
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
on 1.6.0_27 the program cleanly exit with "all done" message
ACTUAL -
java.lang.OutOfMemoryError: Java heap space
Dumping heap to java_pid27708.hprof ...
Heap dump file created [87922226 bytes in 0.956 secs]
Java heap space
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.OutOfMemoryError: Java heap space
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.commons.GeneratorAdapter;
import org.objectweb.asm.commons.Method;
import java.lang.reflect.Constructor;
public class test01 {
void doit(String[] args) throws Exception {
test01classmaker cm = new test01classmaker();
ClassLoader thiscl = getClass().getClassLoader();
test01cl clsloader = new test01cl(thiscl, cm);
for (int i=0; i<1000000; i++) {
String className = String.format("Class%04d", i);
clsloader.loadClass(className);
if ((i % 1000) == 0) {
/* discard old class loader */
clsloader = new test01cl(thiscl, cm);
}
}
}
public static void main(String[] args) throws Exception {
try {
new test01().doit(args);
} catch (OutOfMemoryError e) {
System.out.println(e.getMessage());
System.exit(1);
}
System.out.println("all done");
}
public String greeting() {
return "";
}
}
class test01classmaker implements Opcodes {
byte[] makeClass(String className) {
String superName = "test01";
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES + ClassWriter.COMPUTE_MAXS);
cw.visit(V1_6, ACC_PUBLIC, className, null, superName, null);
MethodVisitor mw = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
mw.visitVarInsn(ALOAD, 0);
mw.visitMethodInsn(INVOKESPECIAL, superName, "<init>", "()V");
mw.visitInsn(RETURN);
mw.visitMaxs(0,0);
mw.visitEnd();
mw = cw.visitMethod(ACC_PUBLIC, "greeting", "()Ljava/lang/String;", null, null);
mw.visitLdcInsn(String.format("hello world! (from %s)", className));
mw.visitInsn(ARETURN);
mw.visitMaxs(0,0);
mw.visitEnd();
cw.visitEnd();
return cw.toByteArray();
}
}
class test01cl extends ClassLoader {
test01classmaker cm;
protected test01cl(ClassLoader parent, test01classmaker cm) {
super(parent);
this.cm = cm;
}
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
Class<?> c;
if (name.startsWith("Class") && Integer.parseInt(name.substring(5)) >= 0) {
byte[] code = cm.makeClass(name);
c = defineClass(name, code, 0, code.length);
} else {
c = super.findClass(name);
}
return c;
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
no known workaround