public void doExecute()

in src/ad/src/main/java/oteldemo/problempattern/GarbageCollectionTrigger.java [43:62]


    public void doExecute() {
        if (System.currentTimeMillis() - lastGC > gc_delay) {
            logger.info("Triggering a manual garbage collection, next one in " + (gc_delay/1000) + " seconds.");
            // clear old data, we want to clear old Entry objects, because their finalization is expensive
            System.gc();

            long total = 0;
            for (int i = 0; i < 10; i++) {
                while (memUtils.getHeapUsage() < 0.9 && memUtils.getObjectPendingFinalizationCount() < maxObjects) {
                    new Entry();
                }
                long start = System.currentTimeMillis();
                System.gc();
                total += System.currentTimeMillis() - start;
            }
            logger.info("The artificially triggered GCs took: " + total + " ms");
            lastGC = System.currentTimeMillis();
        }

    }