I am studying about Java JMX and JConsole. I am curious about the memory management abilities of JConsole. For example, there is a "Perform GC" button in the Memory tab :
Suppose I have simple Java app that eats up memory, something like this :
public class MemoryEater
{
public static void main(String[] args)
{
Vector v = new Vector();
while (true)
{
byte b[] = new byte[1048576];
v.add(b);
Runtime rt = Runtime.getRuntime();
System.out.println( "free memory: " + rt.freeMemory() );
}
}
}
Would there be a way to configure JConsole to prevent this app from consuming X
amount of memory? Or do I need to make a new MBean via JMX ? thanks