I have a very basic programm which is shown below
Main-Method:
Thread.sleep(10000);
MyThread[] threads=new MyThread[16];
for(int i=0;i<16;i++){
threads[i]=new MyThread();
}
for(int i=0;i<16;i++){
threads[i].start();
}
for(int i=0;i<16;i++){
threads[i].join();
}
Threadclass:
public class MyThread extends Thread{
byte[][] queue = new byte[125][];
public void run() {
for(int i=0;i<125;i++){
byte[] tempbyte=new byte[20];
for(int i1=0;i1<20;i1++){
tempbyte[i1]=(byte) 255;
}
queue[i]=tempbyte;
}
try {
Thread.sleep(3000000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
So basicly each thread creates 125 arrays of 20-bytes. With 16 threads this should be 40.000 bytes (16*125*20). Now comes the problem: When I start this programm with the following VM-arguments:
-Xms14000m -XX:NewSize=10000m
and run
jcstat -gc #PID
then it shows around 460 mb for eden (EU). When the main-thread has started and I do jstat again, then it shows around 3000 mb!! Whats the reason for the big heap? I already did a heapdump and the source of heap-waste are a lot of int[] and char[] arrays. They are unreferenced, so i can not track them.