I have profiled a simple program as below and found a large number of char[] instances to be created. Having read here that char[] instances are usually attributed to Strings, I cant see how this is the case for this program. I know there is a char[] 'name' variable in the Thread class, but surely this should only create 10,000 of these, and so I'm wondering where the additional 35,000 threads have come from?
public class untitled {
public static void main(String args[]){
ArrayList<Thread> a = new ArrayList<Thread>();
for(int i = 0; i < 10000; i++){
Thread t1 = new Thread();
a.add(t1);
t1.start();
}
}
}
Here's a screenshot of the profiling memory results. There appears to be a umber of String[] instances also.
Im using this program to isolate some other sections of the profiler. In the full program, the char[] instances increase to ~335,000