Hi

 

Do you have an explanation about this problem?

 

I use an infinite loop in order to saturate allocated memory in a jvm.

But the end of the program is different if I use JDK5 (compile and run) or other (JDK6 or 7)

 

The piece of code:


           Map<Integer, int[][]> mapInt = new HashMap<Integer, int[][]>();
           int sizeX = 500;

               try{
                    for(int i = 0; i < 10000; i++){

                         mapInt.put(i,newint[sizeX][1000]);
                    }
               }catch(OutOfMemoryError e){
                    System.out.println("Exit OutOfMemory error Test with at indix : " + i );
               }finally{
                    mapInt = null;
               }

With JDK5, variable i is 20% bigger than with jdk6 or 7. So it means than more objects are created with former version of java.

Why?

 

Thanks

 

commands :

- compile : javac *.java

- run : java -classpath . -Xmx2000m Test

 

tested on linux redhat 32 bits with :

jdk-1_5_0_17-linux-i586

jdk-6u45-linux-i586

jdk-7u45-linux-i586

FacebookTwitterLinkedin
Pin It
Joomla Tutorials for Beginners