modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java | 6 - modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXPluginLifecycleListener.java | 52 ++++++++++ modules/plugins/jmx/src/main/resources/META-INF/rhq-plugin.xml | 1 pom.xml | 2 4 files changed, 59 insertions(+), 2 deletions(-)
New commits: commit 5911f8751eeea86072ab6c524a2e7bdc1f58166e Merge: 4ae53d1... cc33d33... Author: John Mazzitelli mazz@redhat.com Date: Mon Aug 2 14:49:33 2010 -0400
Merge branch 'master' into permgen-leak
commit 4ae53d12b5b30aafe5362ad5435b0fbe548962b6 Author: John Mazzitelli mazz@redhat.com Date: Mon Aug 2 13:45:07 2010 -0400
clean up some things that we forgot to clean up at shutdown - to help GC
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java index c9c1d54..081e067 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java @@ -78,7 +78,7 @@ import org.rhq.core.pluginapi.util.FileUtils; public class PluginContainer implements ContainerService { private static final PluginContainer INSTANCE = new PluginContainer();
- private static final Log log = LogFactory.getLog(PluginContainer.class); + private final Log log = LogFactory.getLog(PluginContainer.class);
// our management interface private PluginContainerMBeanImpl mbean; @@ -303,7 +303,9 @@ public class PluginContainer implements ContainerService { pluginManager.shutdown();
agentServiceListeners.clear(); + agentServiceListeners = new LinkedHashSet<AgentServiceLifecycleListener>(); agentServiceStreamRemoter = null; + agentRegistrar = null;
purgeTmpDirectoryContents();
@@ -321,6 +323,8 @@ public class PluginContainer implements ContainerService { pluginComponentFactory = null; pluginManager = null;
+ configuration = null; + started = false;
log.info("Plugin container is now shutdown.");
commit 6afb470d31be3c71c9e16544267d74a45e809da0 Merge: 774ed67... 724682f... Author: John Mazzitelli mazz@redhat.com Date: Mon Aug 2 10:44:24 2010 -0400
Merge branch 'master' into permgen-leak
commit 774ed6788f6d14ec7b14f169b2181fbcf20e5302 Author: John Mazzitelli mazz@redhat.com Date: Sat Jul 31 11:35:10 2010 -0400
BZ 615377 - use a new feature in EMS 1.2.13 that lets us clear the EMS classloader factory cache of classloaders and jar files. we now do this in the jmx plugin lifecycle listener.
diff --git a/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXPluginLifecycleListener.java b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXPluginLifecycleListener.java new file mode 100644 index 0000000..3b4984e --- /dev/null +++ b/modules/plugins/jmx/src/main/java/org/rhq/plugins/jmx/JMXPluginLifecycleListener.java @@ -0,0 +1,52 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License, version 2, as + * published by the Free Software Foundation, and/or the GNU Lesser + * General Public License, version 2.1, also as published by the Free + * Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License and the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * and the GNU Lesser General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package org.rhq.plugins.jmx; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.mc4j.ems.connection.support.classloader.ClassLoaderFactory; + +import org.rhq.core.pluginapi.plugin.PluginContext; +import org.rhq.core.pluginapi.plugin.PluginLifecycleListener; + +public class JMXPluginLifecycleListener implements PluginLifecycleListener { + private final Log log = LogFactory.getLog(JMXPluginLifecycleListener.class); + + @Override + public void initialize(PluginContext context) throws Exception { + // no-op + } + + @Override + public void shutdown() { + // so we do not cause EMS classloaders to leak perm gen, we need to clear + // out all caches from the EMS ClassLoaderFactory + try { + ClassLoaderFactory.clearCaches(); + log.debug("Cleared EMS ClassLoaderFactory caches"); + } catch (Exception e) { + log.error("Failed to clear EMS ClassLoaderFactory caches - perm gen may leak", e); + } + } +} diff --git a/modules/plugins/jmx/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jmx/src/main/resources/META-INF/rhq-plugin.xml index 258caee..2c7ca1d 100644 --- a/modules/plugins/jmx/src/main/resources/META-INF/rhq-plugin.xml +++ b/modules/plugins/jmx/src/main/resources/META-INF/rhq-plugin.xml @@ -4,6 +4,7 @@ displayName="Generic JMX" package="org.rhq.plugins.jmx" description="Supports management of JMX MBean Servers via various remoting systems." + pluginLifecycleListener="JMXPluginLifecycleListener" ampsVersion="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:xmlns:rhq-plugin" diff --git a/pom.xml b/pom.xml index 306bbff..e743278 100644 --- a/pom.xml +++ b/pom.xml @@ -85,7 +85,7 @@ <jsf-api.version>1.2_14</jsf-api.version> <jsf-impl.version>1.2_14</jsf-impl.version> <ojdbc5.version>11.2.0.1.0</ojdbc5.version> - <ems.version>1.2.11</ems.version> + <ems.version>1.2.13</ems.version> <postgresql.version>8.4-701.jdbc3</postgresql.version> <h2.version>1.1.117</h2.version> <jtds.version>1.2.2</jtds.version>
commit c1e8353c8ef155fe286658694540bf3e69619737 Merge: 433cafa... 69c6da3... Author: John Mazzitelli mazz@redhat.com Date: Sat Jul 31 11:15:09 2010 -0400
Merge branch 'master' into permgen-leak
commit 433cafa05dc1871710813875d5c21923f716d9a5 Merge: b13693f... 483a1e8... Author: John Mazzitelli mazz@redhat.com Date: Fri Jul 30 17:44:21 2010 -0400
Merge branch 'master' into permgen-leak
commit b13693f2a55c24422be11d38bf23361ed1db3950 Author: John Mazzitelli mazz@redhat.com Date: Fri Jul 23 11:00:46 2010 -0400
BZ 615377 workaround sun bug http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6727821
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java index d6546a2..c9c1d54 100644 --- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java +++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java @@ -31,6 +31,8 @@ import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock;
+import javax.security.auth.login.Configuration; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory;
@@ -114,6 +116,11 @@ public class PluginContainer implements ContainerService { }
private PluginContainer() { + // for why we need to do this, see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6727821 + try { + Configuration.getConfiguration(); + } catch (Throwable t) { + } }
/** @@ -337,6 +344,13 @@ public class PluginContainer implements ContainerService { private void cleanMemory() { Introspector.flushCaches(); LogFactory.releaseAll(); + + // for why we need to do this, see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6727821 + try { + Configuration.setConfiguration(null); + } catch (Throwable t) { + } + System.gc(); }
@@ -563,4 +577,4 @@ public class PluginContainer implements ContainerService { public boolean isInsideAgent() { return (this.configuration != null && this.configuration.isInsideAgent()); } -} \ No newline at end of file +}