ctf: Do not call System.gc() in CTFTrace.close()
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Wed, 16 Apr 2014 22:27:54 +0000 (18:27 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Thu, 17 Apr 2014 15:40:13 +0000 (11:40 -0400)
This call is used to workaround a bug/limitation of MappedByteBuffer
(see JDK-4724038). But CTFTrace.close() is called quite often
(for example, once per trace when closing an experiment), so it is not
the best place to call System.gc(). Instead, only call it when we are
about to delete/rename a trace.

Change-Id: Ib9b346dd04df4f64289ac9db0b976e6b70ff2551
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/25174
Tested-by: Hudson CI
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTrace.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceElement.java

index d0d63dcc1df4474a221a78563a1148d849581c6d..00eac61eb2c2f98cde3668a2b27a8179f5d28de3 100644 (file)
@@ -245,8 +245,6 @@ public class CTFTrace implements IDefinitionScope, AutoCloseable {
                 }
             }
         }
-        // Invoke GC to release MappedByteBuffer objects (Java bug JDK-4724038)
-        System.gc();
     }
 
     // ------------------------------------------------------------------------
index 1daa0f661830ca41fdb463b771bcef2a45ec0ad3..2f654eb5505e78d9abba2ad90b7cfcd219d99903 100644 (file)
@@ -557,6 +557,13 @@ public class TmfTraceElement extends TmfCommonProjectElement implements IActionF
             TmfExperimentElement experiment = (TmfExperimentElement) getParent();
             experiment.closeEditors();
         }
+
+        /*
+         * We will be closing a trace shortly. Invoke GC to release
+         * MappedByteBuffer objects, which some trace types, like CTF, use.
+         * (see Java bug JDK-4724038)
+         */
+        System.gc();
     }
 
     /**
This page took 0.02642 seconds and 5 git commands to generate.