Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.yammer.dropwizard.tasks;
 
 
Performs a full JVM garbage collection (probably).
public class GarbageCollectionTask extends Task {
    private final Runtime runtime;

    
Creates a new GarbageCollectionTask.
    public GarbageCollectionTask() {
        this(Runtime.getRuntime());
    }

    
Creates a new GarbageCollectionTask with the given java.lang.Runtime instance.

Use GarbageCollectionTask() instead.

Parameters:
runtime a java.lang.Runtime instance
    public GarbageCollectionTask(Runtime runtime) {
        super("gc");
        this. = runtime;
    }
    @Override
    @SuppressWarnings("CallToSystemGC")
    public void execute(ImmutableMultimap<StringStringparametersPrintWriter output) {
        final int count = parseRuns(parameters);
        for (int i = 0; i < counti++) {
            output.println("Running GC...");
            output.flush();
            .gc();
        }
        output.println("Done!");
    }
    private static int parseRuns(ImmutableMultimap<StringStringparameters) {
        final ImmutableList<Stringruns = parameters.get("runs").asList();
        if (runs.isEmpty()) {
            return 1;
        } else {
            try {
                return Integer.parseInt(runs.get(0));
            } catch (NumberFormatException ignored) {
                return 1;
            }
        }
    }
New to GrepCode? Check out our FAQ X