views:

75

answers:

1

I've done some searching, but can't seem to find a way to do this.

We'd like to proactively monitor our permgen space via JMX. It seems the best way to do this is through the UsageThreshold attribute on the "PS Perm Gen" MemoryPool. By default, this is set to 0. Is there a way to specify this, or any JMX attribute, as a -D parameter to VM so this can be set automatically at startup? Or is there another mechanism to load JMX attributes automatically?

Thanks.

A: 

Looks like you can set this programmatically - take a look at MemoryPoolMXBean and the section on "Usage Thresholds".

If you have some code to set this value programmatically then it would be trivial to have the code read the value to be set from a properties file or system property or whatever else.

matt b
Yeah, I was hoping there was a simply -D parameter or something and I could specify the fully qualified attribute under MemoryPoolMXBean. I suppose I could do it programmatically and have Spring kick it off when the Servlet container launches.
fender
I did it as a ServletContextListener.First pass: http://pastebin.com/760ckQLV
fender