Trigger a GC once initial configuration has been pushed 03/7003/1
authorRobert Varga <rovarga@cisco.com>
Wed, 14 May 2014 22:04:17 +0000 (00:04 +0200)
committerRobert Varga <rovarga@cisco.com>
Wed, 14 May 2014 22:04:17 +0000 (00:04 +0200)
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 <rovarga@cisco.com>
opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/osgi/ConfigPersisterActivator.java

index 87bbb50..48ae0cb 100644 (file)
@@ -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();
                     }
                 });