From c0b10c35abcdf8038546aa89bf29264720f12a75 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Thu, 15 May 2014 00:04:17 +0200 Subject: [PATCH] Trigger a GC once initial configuration has been pushed This introduces a single run of GC once we complete the initial configuration. The reasoning behind that is that we generate a fair amount of metadata which we are likely to retain unmodified for extended periods of time. We take care to store it in both memory and CPU efficient format, which unfortunately requires us to do some copying around to compact it, leaving a sizeable chunk of garbage on the heap. Change-Id: I81af7d317e3b6f82a431e78b5fb439d8cb5f1997 Signed-off-by: Robert Varga --- .../persist/impl/osgi/ConfigPersisterActivator.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/osgi/ConfigPersisterActivator.java b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/osgi/ConfigPersisterActivator.java index 87bbb50860..48ae0cb91a 100644 --- a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/osgi/ConfigPersisterActivator.java +++ b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/osgi/ConfigPersisterActivator.java @@ -159,6 +159,16 @@ public class ConfigPersisterActivator implements BundleActivator { throw new IllegalStateException(e); } logger.info("Configuration Persister initialization completed."); + + /* + * We have completed initial configuration. At this point + * it is good idea to perform garbage collection to prune + * any garbage we have accumulated during startup. + */ + logger.debug("Running post-initialization garbage collection..."); + System.gc(); + logger.debug("Post-initialization garbage collection completed."); + ConfigPersisterNotificationHandler jmxNotificationHandler = new ConfigPersisterNotificationHandler(platformMBeanServer, persisterAggregator); synchronized (ConfigPersisterActivator.this) { autoCloseables.add(jmxNotificationHandler); @@ -168,7 +178,7 @@ public class ConfigPersisterActivator implements BundleActivator { synchronized (ConfigPersisterActivator.this) { autoCloseables.add(new AutoCloseable() { @Override - public void close() throws Exception { + public void close() { pushingThread.interrupt(); } }); -- 2.36.6