I am testing an application that monitors the health of an application and one of the determining factors is the jvm memory. I am curious as to how I can eat this up so I reach the threshold for testing? Would this work?
ArrayList<Object> list = new ArrayList<Object>();
while(true){
list.add(new Object());
}
similar to chewing through application memory in C where I am constantly malloc'ing things? Or will the garbage collector come and clean all this up for me? Or have I missed the mark entirely?