Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void contextInitialized(ServletContextEvent event) {
- List<MemoryPoolMXBean> memoryPools = ManagementFactory.getMemoryPoolMXBeans();
- for (MemoryPoolMXBean memoryPool : memoryPools) {
- if (memoryPool.getName().contains("Perm Gen") && memoryPool.isUsageThresholdSupported()) {
- MemoryUsage memoryUsage = memoryPool.getUsage();
- long max = memoryUsage.getMax();
- long threshold = Math.round(max * 0.98);
- memoryPool.setUsageThreshold(threshold);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement