gccommand.java
来自「纯java操作系统jnode,安装简单和操作简单的个人使用的Java操作系统」· Java 代码 · 共 53 行
JAVA
53 行
/*
* $Id: GcCommand.java,v 1.1 2003/11/25 11:52:58 epr Exp $
*/
package org.jnode.shell.command;
import java.io.InputStream;
import java.io.PrintStream;
import org.jnode.shell.CommandLine;
import org.jnode.shell.help.*;
/**
* @author epr
*/
public class GcCommand {
public static Help.Info HELP_INFO = new Help.Info(
"gc",
"Start the garbage collector"
);
public static void main(String[] args)
throws Exception {
new GcCommand().execute(new CommandLine(args), System.in, System.out, System.err);
}
/**
* Execute this command
*/
public void execute(
CommandLine cmdLine,
InputStream in,
PrintStream out,
PrintStream err)
throws Exception {
final Runtime rt = Runtime.getRuntime();
out.println("Memory size: " + rt.totalMemory());
out.println("Free memory: " + rt.freeMemory());
out.println("Starting gc...");
long start = System.currentTimeMillis();
rt.gc();
long end = System.currentTimeMillis();
out.println("Memory size: " + rt.totalMemory());
out.println("Free memory: " + rt.freeMemory());
out.println("Time taken : " + (end-start) + "ms");
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?