Will there be a way to configure JConsole to prevent this application from consuming X memory?
From JConsole, we cannot configure / control memory limits. Only option that I see uses -Xmx when starting a java process. Looking at the screenshot below, JConsole provides memory options only as readable but not writeable.

Or do I need to create a new MBean through JMX?
Even if we write our own MBean, I donβt think it is possible to change the memory limits of a java process at runtime. The only way is to adjust the memory limits at startup using -Xms and -Xmx .
If the question is not specific to your sample code, where do you want to limit the number of elements that can be added to Vector through the JMX Bean , and there, limiting memory consumption, which makes it impossible, but I doubt that this is what you are looking for.
Madhusudana reddy sunnapu
source share