Advertisement
Guest User

Untitled

a guest
Mar 18th, 2010
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.47 KB | None | 0 0
  1. public void contextInitialized(ServletContextEvent event) {
  2.     List<MemoryPoolMXBean> memoryPools = ManagementFactory.getMemoryPoolMXBeans();
  3.     for (MemoryPoolMXBean memoryPool : memoryPools) {
  4.         if (memoryPool.getName().contains("Perm Gen") && memoryPool.isUsageThresholdSupported()) {
  5.             MemoryUsage memoryUsage = memoryPool.getUsage();
  6.             long max = memoryUsage.getMax();
  7.             long threshold = Math.round(max * 0.98);
  8.             memoryPool.setUsageThreshold(threshold);
  9.         }
  10.     }
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement