From this discussion i need to write a program to know the answer to question:"if there are more objects than maxvalue of int, then what does jvm assign as an address to an object?",
With the below setting in eclipse.ini
-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20131025-1931
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.6
-Xms6144m
-Xmx6144m
and below program,
class SubClass {
int x = 4;
int getX(){
return x;
}
}
public class Dummy2 {
public static void main(String[] args){
SubClass obj[] = null;
obj = new SubClass[Integer.MAX_VALUE];
for(int i = 0; i < Integer.MAX_VALUE; i++){
obj[i] = new SubClass();
}
SubClass objRef1 = new SubClass();
System.out.println(objRef1);
System.out.println(objRef1.hashCode());
SubClass objRef2 = new SubClass();
System.out.println(objRef2);
System.out.println(objRef2.hashCode());
}
}
am getting error:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
My goal is to see the value of object's address and the hashcode generated for last two objects.
Am using 64 bit jvm running on 64 bit Windows 7 OS which provides virtual space of 8TB for each native user level process. Hardware has 8GB RAM chip.
Please help me!!