public static String makeBasicUsageString() { int present = (int)Math.round(100.0*SoftlyPresent.getUsageTracker().getPercentagePresent()); return Strings.makeSizeString(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())+" / "+ Strings.makeSizeString(Runtime.getRuntime().maxMemory()) + (Runtime.getRuntime().maxMemory() > Runtime.getRuntime().totalMemory() ? " ("+ Strings.makeSizeString(Runtime.getRuntime().totalMemory()) +" real)" : "") + " memory" + "; " + (present>=0 ? present+"% soft-reference maybe retention (of "+SoftlyPresent.getUsageTracker().getTotalEntries()+"); " : "") + Thread.activeCount()+" threads"; }
protected SoftlyPresent(@Nonnull T value) { this.value = new SoftReference<T>(value); TRACKER.track(this, this.value); } @Override
public BrooklynGarbageCollector(BrooklynProperties brooklynProperties, BasicExecutionManager executionManager, BrooklynStorage storage) { this.executionManager = executionManager; this.storage = storage; this.brooklynProperties = brooklynProperties; if (brooklynProperties.getConfig(TRACK_SOFT_MAYBE_USAGE)) SoftlyPresent.getUsageTracker().enable(); executor = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() { @Override public Thread newThread(Runnable r) { return new Thread(r, "brooklyn-gc"); }}); executionManager.addListener(new ExecutionListener() { @Override public void onTaskDone(Task<?> task) { BrooklynGarbageCollector.this.onTaskDone(task); }}); scheduleCollector(true); }